Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook SDK and iOS
    text
    copied!<p>I am trying to post a status using Facebook SDK. Some of the users are already signed in using Facebook. So I have this code:</p> <pre><code> if (FBSession.activeSession.isOpen) { NSLog(@"Already Open%@",[[FBSession activeSession] accessTokenData].accessToken); // NSString *tok = [[FBSession activeSession] accessTokenData].accessToken; NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil]; [[FBSession activeSession] requestNewPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(FBSession *session,NSError *error) { if(!error){ NSLog(@"Publish Permission Granted"); } else { NSLog(@"Publish to get Read Permission"); } }]; //Remove indicator [_activityView removeFromSuperview]; } else { // OPEN Session! [FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) { // if login fails for any reason, we alert if (error) { // show error to user. } else if (FB_ISSESSIONOPENWITHSTATE(status)) { // no error, so we proceed with requesting user details of current facebook session. NSLog(@"----%@",[session accessTokenData].accessToken); //NSString *tok = [session accessTokenData].accessToken; NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil]; [[FBSession activeSession] requestNewPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(FBSession *session,NSError *error) { if(!error){ NSLog(@"Publish Permission Granted"); } else { NSLog(@"Publish to get Read Permission"); } }]; [_activityView removeFromSuperview]; // [self promptUserWithAccountName]; // a custom method - see below: } }]; } </code></pre> <p>So lets focus on the first part which is suppose that the user has open session( the second one is just opening a new one in case that is no session available). How I am going to post a status with a url and a picture after granting publish permissions? Facebook examples are not helping at all. I found some other examples but most of them are outdated.</p> <p>I managed to post a simple post with:</p> <pre><code>FBRequest *postRequest = [FBRequest requestForPostStatusUpdate:@"hi" ]; [postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { // TODO: Check for success / failure here }]; </code></pre> <p>after granding publish permission. I want something similar with url description imgurl and title.</p>
 

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