Udokumentowany proces za pomocą Facebook Connect dla iPhone do przesyłania zdjęć

głosy
1

Po spojrzeniu I przyszedł po drugiej stronie tego postu na forum na Facebooku:

połączyć

Są podawania przedmiotu z Facebooka UIImage. Że wydaje się logiczne, ale gdzie jest to udokumentowane? Dokumentacja API jest uogólnić na wszystkich platformach. Gdzie są szczególne wymagania dla iPhone argumentów i ich typy danych?

Dzięki

Aktualizacja ***** ****** I nadal nie natknąłem wszelkie docs API dotyczących kakao. Zrobiłem jednak zebrać niezbędne informacje o składając w całość informacji na forum, Facebook przykładowy kod, a niektóre kleju.

Mam nadzieję, że będą one wydać coś trochę bardziej konkretny w ciągu najbliższych kilku miesięcy.

Utwórz 15/04/2009 o 05:39
źródło użytkownik
W innych językach...                            


3 odpowiedzi

głosy
-2

Joe Hewitt (autor Facebooku iPhone app) wydany dużej części aplikacji Facebook, jak jego ramach Three20. Jest ona umieszczona na github .

Odpowiedział 15/04/2009 o 07:51
źródło użytkownik

głosy
6

Dla pełności:

Poniższy przykład pokazuje, jak współdziałać z Facebook Connect: https://developers.facebook.com/docs/guides/web/

Wywołania API: https://developers.facebook.com/docs/reference/api/

Jeśli potrzebujesz rozszerzonych uprawnień: https://developers.facebook.com/docs/guides/policy/examples_and_explanations/Extended_Permissions/

Miłym Obj-C otoki na telefon Orchard: http://www.mobileorchard.com/marketing-in-code-part-2-setting-a-users-status-in-facebook-from-an-iphone-app- a-poradnik /

Poniżej jest moja implementacja SessionViewController:

#import "SessionViewController.h"
#import "FBConnect.h"
#import "FBFeedDialog.h"

///////////////////////////////////////////////////////////////////////////////////////////////////
// This application will not work until you enter your Facebook application's API key here:

static NSString* kApiKey = @"XXXXXXXXXXXXXXXXXX";

// Enter either your API secret or a callback URL (as described in documentation):
static NSString* kApiSecret = @"XXXXXXXXXXXXXXXXXX"; // @"<YOUR SECRET KEY>";

///////////////////////////////////////////////////////////////////////////////////////////////////

@implementation SessionViewController

@synthesize label = _label;
@synthesize anImage;

- (void)done:(id)sender{

    [self dismissModalViewControllerAnimated:YES];


}

///////////////////////////////////////////////////////////////////////////////////////////////////
// NSObject

- (id)init {
    if (self = [super init]) {
        _session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
    }
    return self;
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  if (self = [super initWithNibName:@"SessionViewController" bundle:nibBundleOrNil]) {
      _session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];

  }
  return self;
}

- (void)dealloc {
    [_session release];
    [anImage release];
    [super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// UIViewController

- (void)viewDidLoad {
  [_session resume];
  _loginButton.style = FBLoginButtonStyleWide;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  return NO;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// FBDialogDelegate

- (void)dialog:(FBDialog*)dialog didFailWithError:(NSError*)error {
  _label.text = [NSString stringWithFormat:@"Error(%d) %@", error.code,
    error.localizedDescription];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// FBSessionDelegate

- (void)session:(FBSession*)session didLogin:(FBUID)uid {
  _permissionButton.hidden = NO;
  _feedButton.hidden = NO;

  NSString* fql = [NSString stringWithFormat:
    @"select uid,name from user where uid == %lld", session.uid];

  NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
  [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}

- (void)sessionDidLogout:(FBSession*)session {
  _label.text = @"";
  _permissionButton.hidden = YES;
  _feedButton.hidden = YES;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// FBRequestDelegate

- (void)request:(FBRequest*)request didLoad:(id)result {

    if([result isKindOfClass:[NSArray class]]){
        NSArray* users = result;
        NSDictionary* user = [users objectAtIndex:0];
        NSString* name = [user objectForKey:@"name"];
        _label.text = [NSString stringWithFormat:@"Logged in as %@", name];
    }  

}

- (void)request:(FBRequest*)request didFailWithError:(NSError*)error {
  _label.text = [NSString stringWithFormat:@"Error(%d) %@", error.code,
    error.localizedDescription];
}

///////////////////////////////////////////////////////////////////////////////////////////////////

- (IBAction)askPermissionForPhotoUpload:(id)target {
    FBPermissionDialog* dialog = [[[FBPermissionDialog alloc] init] autorelease];
    dialog.delegate = self;
    dialog.permission = @"photo_upload";
    [dialog show];
}
- (IBAction)publishPhoto:(id)target{

    NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
    [args setObject:self.anImage forKey:@"image"];  
    FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
    [uploadPhotoRequest call:@"photos.upload" params:args];
}


- (void)askPermission:(id)target {
  FBPermissionDialog* dialog = [[[FBPermissionDialog alloc] init] autorelease];
  dialog.delegate = self;
  dialog.permission = @"status_update";
  [dialog show];
}

- (void)publishFeed:(id)target {
  FBFeedDialog* dialog = [[[FBFeedDialog alloc] init] autorelease];
  dialog.delegate = self;
  dialog.templateBundleId = 9999999;
  dialog.templateData = @"{\"key1\": \"value1\"}";
  [dialog show];
}

@end
Odpowiedział 16/12/2009 o 18:24
źródło użytkownik

Odpowiedział 28/06/2011 o 13:41
źródło użytkownik

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more