Facebook iOS SDK 3.1在朋友墙上发布图片错误 [英] Facebook iOS SDK 3.1 post image on friends wall error

查看:125
本文介绍了Facebook iOS SDK 3.1在朋友墙上发布图片错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using the latest Facebook iOS SDK 3.1.1 while trying to post UIImage on friends wall i`m getting error 5 (Error: HTTP status code: 403).

如果我尝试将图片发布到我的墙上它运作良好,但不是我的朋友之一。

if i try to post the image on MY wall its working well, but not of one of my friends.

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

My Code: 1. before posting i am checking if the user has the right permissions, when he does i am making

-(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];
             }
         }];



    }
}
}

提及,如果我改变

startWithGraphPath:[NSString stringWithFormat:@%@ / photos,userID]

startWithGraphPath:[NSString stringWithFormat:@"me/photos",userID]

工作正常。

我做错了什么?
我一直试图寻找答案,但没有任何帮助。
谢谢!

what am i doing wrong? i have been trying to look for answers but nothing helped. Thank you!

推荐答案

这是因为你没有足够的权限级别。
正如FB文档所说:

This happens because you have insufficient permissions level. As FB docs say:


Insufficient_scope请求需要比访问令牌提供的
更高的权限。资源服务器应该用
响应HTTP 403(Forbidden)状态代码,并且可以包含scope
属性以及访问受保护资源所需的范围。

Insufficient_scope The request requires higher privileges than provided by the access token. The resource server SHOULD respond with the HTTP 403 (Forbidden) status code and MAY include the "scope" attribute with the scope necessary to access the protected resource.

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

You must obtain advanced permissions to post to another user's wall. The permission you need is @"publish_stream" which "enables your app to post content, comments, and likes to a user's stream and to the streams of the user's friends. This is a superset publishing permission which also includes publish_actions."(c)

最新的更改会迫使您将所需的权限划分为两个级别 - 基本,这样您就可以阅读有关用户和高级(帖子等)
这里的权限列表:
扩展权限列表

The latest changes force you to divide the permissions needed onto two levels - basic which allows you to read basic information about the user and advanced (post, etc.) Here's permissions lists: Extended permissions list

这意味着您需要在两个步骤中请求适当的权限。首先获得基础,然后要求提前。

This means that you have to ask for appropriate permissions into two steps. First obtain basic and then ask for advanced.

这篇关于Facebook iOS SDK 3.1在朋友墙上发布图片错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆