首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS 7- Facebook:查看分享结果

iOS 7- Facebook:查看分享结果
EN

Stack Overflow用户
提问于 2014-04-23 02:24:54
回答 1查看 535关注 0票数 0

你有没有想过检查一下Facebook wall上的分享是否成功?

我想知道是用户从SDK的界面取消了共享操作,还是由于技术问题而没有发布。

我在iOS 7上使用框架"FacebookSDK/FacebookSDK.h“的FBDialogs

presentShareDialogWithPhotoParams这样的处理程序块永远不会被调用。

提前谢谢。再见。

EN

回答 1

Stack Overflow用户

发布于 2014-04-25 17:00:58

当您呈现提要对话框时,您可以使用以下代码来检测用户何时成功分享帖子、何时用户取消操作或何时发生错误:

代码语言:javascript
复制
[FBWebDialogs presentFeedDialogModallyWithSession:nil
                                       parameters:params
                                          handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                              if (error) {
                                                  // An error occurred, we need to handle the error
                                                  // See: https://developers.facebook.com/docs/ios/errors
                                                  NSLog(@"%@", [NSString stringWithFormat:@"Error publishing story: %@", error.description]);
                                              } else {
                                                  if (result == FBWebDialogResultDialogNotCompleted) {
                                                      // User cancelled.
                                                      NSLog(@"User cancelled.");
                                                  } else {
                                                      // Handle the publish feed callback
                                                      NSDictionary *urlParams = [self parseURLParams:[resultURL query]];

                                                      if (![urlParams valueForKey:@"post_id"]) {
                                                          // User cancelled.
                                                          NSLog(@"User cancelled.");

                                                      } else {
                                                          // User clicked the Share button
                                                          NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
                                                          NSLog(@"result %@", result);
                                                      }
                                                  }
                                              }
                                          }];

当你显示分享对话框时,你可以让来自服务器的以下错误来处理是否成功分享了帖子:

代码语言:javascript
复制
[FBDialogs presentShareDialogWithLink:params.link
                                     name:params.name
                                  caption:params.caption
                              description:params.description
                                  picture:params.picture
                              clientState:nil
                                  handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
                                      if(error) {
                                          // An error occurred, we need to handle the error
                                          // See: https://developers.facebook.com/docs/ios/errors
                                          NSLog(@"%@", [NSString stringWithFormat:@"Error publishing story: %@", error.description]);
                                      } else {
                                          // Success
                                          NSLog(@"result %@", results);
                                      }
                                  }];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23227398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档