【问题标题】:simple way to publish to wall with ios SDK 3.1使用 ios SDK 3.1 发布到墙上的简单方法
【发布时间】:2013-01-24 16:27:16
【问题描述】:

我刚用 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];

                     }

【问题讨论】:

  • 您检查过会话的状态吗?你可以记录状态的值吗?

标签: ios facebook


【解决方案1】:
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"];
}
       }];
            }
            }];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多