繁体   English   中英

iOS 7-Facebook:检查共享结果

[英]iOS 7 - Facebook: check share result

您是否需要检查Facebook墙上的共享是否成功完成?

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

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

永远不会调用诸如presentShareDialogWithPhotoParams之类的方法的处理程序块。

提前致谢。 再见。

显示提要对话框时,可以使用以下代码来检测用户何时成功共享帖子,何时取消操作或何时发生错误:

[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);
                                                      }
                                                  }
                                              }
                                          }];

当您显示分享对话框时,可以让服务器成功处理以下错误,无论帖子是否成功共享:

[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);
                                      }
                                  }];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM