5

我刚刚使用 SDK iOS 3.1 启动了一个新应用程序,我注意到现在读写权限是分开的。

我正在寻找一种简单的方法来发布到用户墙,但我对授权机制有点困惑

如果我可以在 openActiveSessionWithReadPermissions 的 CompletionHandler 中获得写权限,我会收到以下错误

*** 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.'

completionHandler 听起来动作已经完成,所以我不明白这段代码有什么问题。

有什么建议么 ?

-(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];

                     }
4

1 回答 1

0
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"];
}
       }];
            }
            }];
于 2013-07-31T10:44:13.123 回答