iOS:使用FBWebDialogs在选定的FB好友的墙上张贴

时间:2014-03-24 06:59:21

标签: ios iphone facebook facebook-graph-api facebook-ios-sdk

我可以使用FBWebDialogs将图像发布到facebook朋友的墙上。我正在寻找的是如何将图像发布给多个朋友... 以下是我的单一帖子的代码

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"Sharing Tutorial", @"name",
                               @"Build great social apps and get more installs.", @"caption",
                               @"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
                               @"https://developers.facebook.com/docs/ios/share/", @"link",
                               @"http://i.imgur.com/g3Qc1HN.png", @"picture",
                               @"100006771363037",@"to",
                                nil];

// Show the feed dialog
[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(@"Error publishing story: %@", error.description);
                                            } else {
                                              if (result == FBWebDialogResultDialogNotCompleted) {
                                                // User canceled.
                                                NSLog(@"User cancelled.");
                                              } else {
                                                // Handle the publish feed callback
                                                NSDictionary *urlParams = [self parseURLParams:[resultURL query]];

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

                                                } else {
                                                  // User clicked the Share button

                                                    NSLog(@"fb web dialog result=====>%@",result);
                                                  NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
                                                  NSLog(@"result %@", result);
                                                }
                                              }
                                            }
                                          }];

在@“to”字段中添加以逗号分隔的朋友profile_id时获取error.Added屏幕截图如下

1 个答案:

答案 0 :(得分:0)

您无法在 Feed对话中的to参数中添加多个ID。事实上,没有办法立即向多个朋友发布Feed。您必须分别为每个朋友调用对话框。

根据documentationto是:

  

此故事将发布到的个人资料的ID或用户名。如果未指定,则默认为from。的值。