1

我正在使用 facebook_skd_3.1 (Xcode ios 4.5) 我通过调用 FBFriendPickerViewController 获得了朋友列表,在单击完成按钮时我试图
在选定的朋友墙上发布消息但我收到了这个错误:- 警告:尝试从视图控制器中关闭在演示或解散过程中!
2012-12-06 19:37:09.187 ........项目 [5474:19a03] 错误:HTTP 状态代码:403

警报视图中的错误

 error =Error Domain=com.facebook.sdk code=5" ..........
 message = "(#200)the user hasn't authorized the application to perform this action";
 type = OAuthException
 };
 };

 code=403;

 com.acebook.sdk:HTTPStatuscode=403}

代码 :-

  -(void)facebookViewControllerDoneWasPressed:(id)sender {
  NSString* userid;

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


    }

  NSMutableDictionary* dictaram = [[NSMutableDictionary alloc]
    initWithObjectsAndKeys:@"like this!", @"message", nil];
  [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed", userid] 
       parameters:params HTTPMethod:@"POST"  
  completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
  {

      UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Shared"
      message:[NSString     stringWithFormat:@ %@! error=%@", fbUserName, error]
                                                        delegate:nil
                                              cancelButtonTitle:@"OK"
                                               otherButtonTitles:nil];
      [alertView show];
   }
   ];

   [self dismissModalViewControllerAnimated:YES];

在此处输入图像描述

我需要一些权限还是有一些编码错误请帮忙。

提前致谢。

4

2 回答 2

0

请延迟一段时间后关闭视图控制器。

于 2012-12-10T15:21:51.510 回答
0

我已经通过在委托中重新授权如下权限来解决这个问题,我已经读取了会话的权限,因此不适用于发布。在 ButtonAction 中写入以下代码,您将获得正确的输出。

 NSArray *permissions =[NSArray arrayWithObjects:@"publish_actions",@"publish_stream",@"manage_friendlists", nil];

[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends
                                           completionHandler:^(FBSession *session, NSError *error) {
                                               /* handle success + failure in block */
                                           }];
于 2012-12-13T11:24:35.603 回答