0

我正在尝试使用 Facebook Feed Dialog 发布文本和图像,我可以发布到我自己的墙上,但无法标记朋友。我可以从 FBFriendPickerViewController 中选择一个朋友,但是当我点击完成但我收到返回错误 5。在 stackoverflow 问题之一(发布状态更新时 ios-Facebook SDK 3.0 错误 5)中,有几种方法可以导致此错误,我已经纠正了该问题中提到的所有可能方式。

并且提要对话框是否正确 [FBRequestConnection startWithGraphPath:@"%@/feed" 参数:params

这是我的代码,

- (IBAction)pickFriendsList:(UIButton *)sender
{
    FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init];
    friendPickerController.title = @"Pick Friends";
    [friendPickerController loadData];

    [friendPickerController presentModallyFromViewController:self animated:YES handler:
     ^(FBViewController *sender, BOOL donePressed) {

         if (!donePressed) {
             return;
         }

         NSString* fid;
         NSString* fbUserName;

         for (id<FBGraphUser> user in friendPickerController.selection)
         {
             NSLog(@"\nuser=%@\n", user);
             fid = user.id;

             fbUserName = user.name;

             NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"aaaaaa", @"message", @"http://webecoist.momtastic.com/wp-content/uploads/2009/01/nature-wonders.jpg", @"picture", @"My Susfsdfsdfs sdf sfsdfp", @"name", nil];

             NSLog(@"\nparams=%@\n", params);


             [FBRequestConnection startWithGraphPath:@"%@/feed" parameters:params HTTPMethod:@"POST"
                                   completionHandler:^(FBRequestConnection *connection, id result, NSError *error)


              {
                  //Tell the user that it worked.
                  UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Shared"
                                                                      message:[NSString stringWithFormat:@"Invited %@! error=%@", fbUserName, error]
                                                                     delegate:nil
                                                            cancelButtonTitle:@"OK"
                                                            otherButtonTitles:nil];

                  [alertView show];
                  NSLog(@"%@ alertview description",alertView.message);

              }
              ];

         }

     }];

}

在此处输入图像描述在此处输入图像描述在此处输入图像描述在此处输入图像描述

错误 :

> Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be
> completed. (com.facebook.sdk error 5.)" UserInfo=0xa157bf0
> {com.facebook.sdk:HTTPStatusCode=500,
> com.facebook.sdk:ParsedJSONResponseKey={
>     body =     {
>         error =         {
>             code = 1;
>             message = "An unknown error has occurred.";
>             type = OAuthException;
>         };
>     };
>     code = 500; }, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x9491490, state: FBSessionStateOpen, loginHandler: 0x946f8d0, appID:
> 511223775602729, urlSchemeSuffix: ,
> tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x948f2b0>,
> expirationDate: 2013-06-15 05:04:17 +0000, refreshDate: 2013-04-16
> 10:36:11 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000,
> permissions:( )>}
4

2 回答 2

1

FB User ID注意:您的代码中缺少

更改您的代码如下:

[FBRequestConnection
             startWithGraphPath:[NSString stringWithFormat:@"%@/feed", fid]
             parameters:params
             HTTPMethod:@"POST"
             completionHandler:^(FBRequestConnection *connection,
                                 id result,
                                 NSError *)

问候,

于 2013-04-16T02:04:59.893 回答
0

您可以使用签到或 Open Graph 操作来标记 Facebook 中的朋友,因为签到应用需要获得许可,但可以使用基本应用设置。但是对于 Open Graph,您需要进行多项设置。您可以查看此处

于 2013-04-15T06:44:13.760 回答