Iphone Facebook iOS SDK 3.1在好友墙上发布图像错误

Iphone Facebook iOS SDK 3.1在好友墙上发布图像错误,iphone,objective-c,ios,facebook,post,Iphone,Objective C,Ios,Facebook,Post,我正在使用最新的Facebook iOS SDK 3.1.1 尝试在朋友墙上发布UIImage时,我收到错误5(错误:HTTP状态代码:403) 如果我想把这张照片贴在墙上,效果会很好,但我的一个朋友却不行 我的代码: 1.在发布之前,我正在检查用户是否拥有正确的权限,当他拥有权限时,我正在进行 -(void)postImageOnFriendsWall:(UIImage*)image FriendsArray:(NSArray*)friends { // if we don't hav

我正在使用最新的Facebook iOS SDK 3.1.1 尝试在朋友墙上发布UIImage时,我收到错误5(错误:HTTP状态代码:403)

如果我想把这张照片贴在墙上,效果会很好,但我的一个朋友却不行

我的代码: 1.在发布之前,我正在检查用户是否拥有正确的权限,当他拥有权限时,我正在进行

-(void)postImageOnFriendsWall:(UIImage*)image FriendsArray:(NSArray*)friends
{
    // if we don't have permission to announce, let's first address that
    if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound)
    {

    [FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
                                               defaultAudience:FBSessionDefaultAudienceFriends
                                             completionHandler:^(FBSession *session, NSError *error)
     {
         if (!error)
         {
             // re-call assuming we now have the permission
             [self postImageOnFriendsWall:image FriendsArray:friends];

         }
         else
         {
             UIAlertView *alertView = [[UIAlertView alloc]  initWithTitle:@"Error"                        message:error.localizedDescription                                                                                                delegate:nil                                                                                         cancelButtonTitle:@"OK"
                                                        otherButtonTitles:nil];
             [alertView show];
         }

     }];
}
else
{

    // can post image
    for (id<FBGraphUser> user in friends)
    {


        NSString *userID = user.id;
        NSLog(@"trying to post image of %@ wall",userID);
        NSMutableDictionary  *postVariablesDictionary = [[NSMutableDictionary alloc] init];
        [postVariablesDictionary setObject:UIImagePNGRepresentation(image) forKey:@"picture"];
        [postVariablesDictionary setObject:@"my image" forKey:@"message"];

        [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/photos",userID] parameters:postVariablesDictionary HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
         {
             if (error)
             {
                 //showing an alert for failure
                 UIAlertView *alertView = [[UIAlertView alloc]  initWithTitle:@"Facebook" message:error.localizedDescription                                                                                                delegate:nil   cancelButtonTitle:@"OK"              otherButtonTitles:nil];
                 [alertView show];
             }
             else
             {
                 //showing an alert for success
                 UIAlertView *alertView = [[UIAlertView alloc]  initWithTitle:@"Facebook" message:@"Shared the photo successfully"                                                                                                delegate:nil   cancelButtonTitle:@"OK"              otherButtonTitles:nil];
                 [alertView show];
             }
         }];



    }
}
}
工作正常

我做错了什么? 我一直在努力寻找答案,但毫无帮助。
谢谢大家!

发生这种情况是因为您没有足够的权限级别。 正如FB医生所说:

作用域不足请求所需的权限高于 由访问令牌提供。资源服务器应以 HTTP 403(禁止)状态代码,可能包括“范围” 属性,该属性具有访问受保护资源所需的作用域

您必须获得高级权限才能发布到其他用户的墙。您需要的权限是@“publish_stream”,它“允许您的应用程序向用户的流和用户朋友的流发布内容、评论和喜欢。这是一个超集发布权限,还包括发布操作。”(c)

最新的更改迫使您将所需的权限分为两个级别-基本权限,允许您阅读有关用户的基本信息和高级权限(帖子等) 以下是权限列表:


这意味着您必须分两步请求适当的权限。首先获取基本信息,然后获取高级信息。

你必须检查你的facebook应用程序id,有时会出现问题。因为我也有同样的问题,无法将wall发布到我的朋友墙上,但更改facebook应用程序id和它的工作非常完美

哇!谢谢你,伙计!我甚至说不出我有多感激它!它工作得很好!节省了我很多时间:)一点也不,如果答案对你有帮助,你应该接受。单击选票计数附近的复选标记。
startWithGraphPath:[NSString stringWithFormat:@"me/photos",userID]