使用 FBWebDialogs (Facebook SDK 3.5) 成功发布后的 nil resultURL

Posted

技术标签:

【中文标题】使用 FBWebDialogs (Facebook SDK 3.5) 成功发布后的 nil resultURL【英文标题】:nil resultURL after successfully posting with FBWebDialogs (Facebook SDK 3.5) 【发布时间】:2013-04-23 22:22:11 【问题描述】:

我正在我的应用程序中集成 Facebook 以共享网站链接。我正在使用 Feed 对话框来完成此操作,并且我正在关注本教程:https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/。

我已成功登录并在 Facebook 上发帖,但我想在发帖成功后添加一条消息。该教程内置了这个,但每次我发布时,我都会在日志中看到“用户取消故事发布。”,这是用户单击取消时显示的消息。此外,我已通过调试器确认处理程序收到的参数resultURL 始终为零,即使在成功发布时也是如此。

起初我以为这是我的Facebook App 的配置问题,但我决定做一个测试。我打开了框架附带的RPSSample,在clickInviteFriends 视图控制器中的clickInviteFriends 方法中的presentRequestsDialogModallyWithSession 调用中添加了一个完成处理程序,并且在那里成功发布的帖子我也得到了一个零resultURL

我错过了什么?

我知道 3.5 SDK 版本非常新,但根据文档,在通过 Facebook 网络对话框 发布后,我应该会得到一个有效的 resultURL 参数,所以我不确定它是否是一个错误,或者我在某处缺少一些回调或处理程序。

以防万一,这是我对 Feed Web 对话框的调用。与教程中的相比,它有细微的变化(实际上更简单)

- (void)publish: (EntityToShare *)entityToShare 
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
 entityToShare.link, @"link",
 nil];

// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
                                       parameters:params
                                          handler:
 ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) 
     if (error) 
         // Error launching the dialog or publishing a story.
         NSLog(@"Error publishing story.");
      else 
         if (result == FBWebDialogResultDialogNotCompleted) 
             // User clicked the "x" icon
             NSLog(@"User canceled story publishing.");
          else 
             // Handle the publish feed callback
             NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
             if (![urlParams valueForKey:@"post_id"]) 
                 // User clicked the Cancel button
                 NSLog(@"User canceled story publishing.");
              else 
                 // User clicked the Share button
                 NSString *msg = [NSString stringWithFormat:
                                  @"Posted story, id: %@",
                                  [urlParams valueForKey:@"post_id"]];
                 NSLog(@"%@", msg);
                 // Show the result in an alert
                 [[[UIAlertView alloc] initWithTitle:@"Result"
                                             message:msg
                                            delegate:nil
                                   cancelButtonTitle:@"OK!"
                                   otherButtonTitles:nil]
                  show];
             
         
     
 ];

【问题讨论】:

遇到同样的问题。 【参考方案1】:

我们已经解决了这个问题,很快就会推出。

已编辑:

这已在 SDK 版本 3.5.1 中得到修复 在这里查看:https://developers.facebook.com/ios/

【讨论】:

我遇到了和 Diego 一样的问题。你预计什么时候能修好? 太棒了!谢谢你这么快回答。这让我发疯了。那么,这是服务器问题还是 SDK 有问题? 我等的这么急,难道只是一个不会影响我本机代码的api bug? 编辑了我的回复。是 SDK 中的错误。我们已经推出了修复程序。 我正在使用新的 sdk 3.7,但我仍然遇到同样的问题

以上是关于使用 FBWebDialogs (Facebook SDK 3.5) 成功发布后的 nil resultURL的主要内容,如果未能解决你的问题,请参考以下文章

使用 FBWebDialogs (Facebook SDK 3.5) 成功发布后的 nil resultURL

Facebook FBWebDialogs 参数一次邀请多个朋友

FBWebDialogs 缺少用于验证用户的会话 Cookie

我可以通过 presentFeedDialogModallyWithSession 传递给 FBWebDialogs 的全套合法参数是啥

我是不是需要创建 Facebook 应用才能使用 Facebook 登录?

Facebook OAuth 安全使用护照-facebook