Easy way to post to the wall with ios SDK 3.1

I just started a new application with iOS 3.1 SDK, I noticed that read and write permissions are now separate.

I'm looking for an easy way to post to a userโ€™s wall, but I'm a little confused with the authorization mechanism

If I can write permissions in the CompletionHandler openActiveSessionWithReadPermissions, I get the following error

*** Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: It is not valid to reauthorize while a previous reauthorize call has not yet completed.'

completeHandler sounds like the action is complete, so I donโ€™t understand what the problem is with this code.

Any suggestions?

-(void)askWritePerms
{
NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil];

[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions
                           defaultAudience:FBSessionDefaultAudienceFriends
                         completionHandler:^(FBSession *session, NSError *error) {


  }];

}


 - (IBAction)publishFB:(id)sender
 {


        NSArray *permissions = [NSArray arrayWithObjects:@"email", nil];

       [FBSession openActiveSessionWithReadPermissions:permissions
                                   allowLoginUI:YES
                              completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                            [self askWritePerms];

                     }
+5
source share
1 answer
For publishing in wall in facebook use the following code
[[FBSession activeSession] reauthorizeWithPublishPermissions:@[ @"publish_stream",@"publish_actions" ] defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *authSession, NSError *authError) {

            // If auth was successful, create a status update FBRequest
            if (!authError) {
 NSMutableDictionary* photosParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                                     imageurl,@"source",
                                                     urlstring,@"link",@"Appname",@"name",@"Your app description",@"description",
                                                     nil];


                [FBRequestConnection startWithGraphPath:@"me/feed" parameters:photosParams HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                if (error)
                {
                    [self showAlert:@"Connection Error...Try Again"];
}
       }];
            }
            }];
0
source

All Articles