在朋友墙上发布消息时出现集成错误?

时间:2012-12-06 14:16:45

标签: iphone ios facebook ios5

我正在使用facebook_skd_3.1(Xcode ios 4.5)我通过电话获得了好友列表 FBFriendPickerViewController,点击完成按钮我试图发布消息
在选定的朋友墙上但我得到了这个错误: - 警告:尝试从视图控制器中解除 正在进行演示或解雇! 2012-12-06 19:37:09.187 ........ project [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];

enter image description here

我是否需要一些权限或者有一些编码错误请帮助。

提前谢谢。

2 个答案:

答案 0 :(得分:0)

请在延迟一段时间后解除viewcontroller。

答案 1 :(得分: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 */
                                           }];