Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A summarized answer that outlines the process...key point is to include the access_token in the graph calls since the facebook-ios-sdk doesn't do this automatically:</p> <p>1)Update to the latest facebook-ios-sdk.<br/> 2)Instantiate with app id.</p> <pre><code> self.facebook = [[Facebook alloc] initWithAppId:kApplicationFBID]; </code></pre> <p>3) Authorize the app including publish_stream</p> <pre><code> NSArray * neededPermissions = [[[NSArray alloc] initWithObjects:@"user_about_me", @"publish_stream", @"user_photos", nil] autorelease]; [facebook authorize:neededPermissions delegate:appDelegate]; </code></pre> <p>4) Ensure app delegate fBDidLogin captures and stores the access token &amp; expiration in user defaults (for later optimization of login process).</p> <pre><code> -(void)fbDidLogin { DebugLog(@"New Access Token: %@", [facebook accessToken] ); NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"]; [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"]; [defaults synchronize]; } </code></pre> <p>5) Confirm valid access token (non nil and not expired)...otherwise re authorize app per above.<br/> 6) Capture image to UIImage &amp; call this noting the critical addition of the access_token. This will auto create an album for your app and put the image there and post it on the wall per my testing. <pre><code></p> <pre><code>-(void)postImageToAlbum:(UIImage *)image { NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: image, @"source", @"caption desc", @"message", nil]; [facebook requestWithGraphPath:[NSString stringWithFormat:@"/me/photos?access_token=%@", self.facebook.accessToken] andParams:params andHttpMethod:@"POST" andDelegate:self]; } </code></pre> <p></pre></code> 7) Check for id result in FBRequestDelegate method </p> <pre><code> -(void)request:(FBRequest *)request didLoad:(id)result { NSLog(@"Request didLoad: %@ ", [request url ]); if ([result isKindOfClass:[NSArray class]]) { result = [result objectAtIndex:0]; } if ([result isKindOfClass:[NSDictionary class]]){ } if ([result isKindOfClass:[NSData class]]) { } NSLog(@"request returns %@",result); } </code></pre> <p>8) DO NOT USE a test user account for testing...currently it will auth the test account and provide an access token but when you try to use graph api it will return unexpected errors. You may be alright if you are using web version vs native app setting in dev.facebook.com since supposedly you can create test users and associate them with the app but I haven't tried that.</p> <p>Good Luck!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload