将照片上传至 Facebook 粉丝页面

发布于 2024-10-15 05:08:33 字数 2233 浏览 2 评论 0原文

这是我用来将照片上传到我的粉丝页面的代码关键点,

_permissions =  [[NSArray arrayWithObjects:@"read_stream", @"offline_access", @"publish_stream", @"manage_pages", @"user_photos", @"friends_photos",nil] retain]; 

[_facebook requestWithGraphPath:@"/me/accounts" andDelegate:self];

我从结果中解析页面 access_token 并将其用于模拟页面的下一个请求,并且我可以成功地从结果中解析出页面所有者信息,所以我猜我的 access_token 没问题

 - (IBAction)getUserInfo:(id)sender {
            _facebook.accessToken = self.pageAccessToken;
          [_facebook requestWithGraphPath:@"me" andDelegate:self];
        }

,但是如果我尝试像这样将照片上传到我的页面相册:

- (IBAction)uploadPhoto:(id)sender {

          NSString *path = @"http://dl.dropbox.com/u/xxxxxxx/Icon.png";
          NSURL *url = [NSURL URLWithString:path];
          NSData *data = [NSData dataWithContentsOfURL:url];
          UIImage *img  = [[UIImage alloc] initWithData:data];

          NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                         img, @"picture",
                                         nil];



            _facebook.accessToken = self.pageAccessToken;


          [_facebook requestWithMethodName:@"photos.upload"
                                 andParams:params
                             andHttpMethod:@"POST"
                               andDelegate:self];

          //or like
          // [_facebook requestWithGraphPath:@"/me/photos" ...
          // [_facebook requestWithGraphPath:@"/<PAGE_ID>/photos" ...
          // [_facebook requestWithGraphPath:@"/<ALBUM_ID>/photos" ...

          [img release];
        }

我总是收到错误:(

Error Domain=facebookErrDomain Code=190 "The operation couldn’t be completed. (facebookErrDomain error 190.)" UserInfo=0x15fca0 {request_args=(
{
key = method;
value = "photos.upload";
},
{
key = sdk;
value = ios;
},
{
key = "sdk_version";
value = 2;
},
{
key = "access_token";
value = "1939755xx612731|8ceab6c65ce0194d079f41ef-1068726246|3x2697618282|xdSRakxsdjezx9N1dnr9cRe6ICk";
},
{
key = format;
value = json;
}
), error_msg=Invalid OAuth 2.0 Access Token, error_code=190}

}

注意:我稍微修改了 access_token 只是为了保护)

here's my code keypoints that I'm using in order to upload photo to my fan page

_permissions =  [[NSArray arrayWithObjects:@"read_stream", @"offline_access", @"publish_stream", @"manage_pages", @"user_photos", @"friends_photos",nil] retain]; 

[_facebook requestWithGraphPath:@"/me/accounts" andDelegate:self];

I parse the page access_token from results and use it for next requests impersonating page, and I can successifuly parse out page owner info from the result, so I guess my access_token is ok

 - (IBAction)getUserInfo:(id)sender {
            _facebook.accessToken = self.pageAccessToken;
          [_facebook requestWithGraphPath:@"me" andDelegate:self];
        }

But If I try to upload photo to my page album like this:

- (IBAction)uploadPhoto:(id)sender {

          NSString *path = @"http://dl.dropbox.com/u/xxxxxxx/Icon.png";
          NSURL *url = [NSURL URLWithString:path];
          NSData *data = [NSData dataWithContentsOfURL:url];
          UIImage *img  = [[UIImage alloc] initWithData:data];

          NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                         img, @"picture",
                                         nil];



            _facebook.accessToken = self.pageAccessToken;


          [_facebook requestWithMethodName:@"photos.upload"
                                 andParams:params
                             andHttpMethod:@"POST"
                               andDelegate:self];

          //or like
          // [_facebook requestWithGraphPath:@"/me/photos" ...
          // [_facebook requestWithGraphPath:@"/<PAGE_ID>/photos" ...
          // [_facebook requestWithGraphPath:@"/<ALBUM_ID>/photos" ...

          [img release];
        }

I always get error:

Error Domain=facebookErrDomain Code=190 "The operation couldn’t be completed. (facebookErrDomain error 190.)" UserInfo=0x15fca0 {request_args=(
{
key = method;
value = "photos.upload";
},
{
key = sdk;
value = ios;
},
{
key = "sdk_version";
value = 2;
},
{
key = "access_token";
value = "1939755xx612731|8ceab6c65ce0194d079f41ef-1068726246|3x2697618282|xdSRakxsdjezx9N1dnr9cRe6ICk";
},
{
key = format;
value = json;
}
), error_msg=Invalid OAuth 2.0 Access Token, error_code=190}

}

(note: i've modified slightly access_token just for protection)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荒路情人 2024-10-22 05:08:33

嘿 jackiedigital,我的“manage_pages”权限仅与 Graph API 兼容。
查看此页面上的最后一个权限: http://developers.facebook.com/docs/authentication /权限/

Hey jackiedigital, I this the "manage_pages" permission is only compatible with the Graph API.
Check out the Last permission on this page: http://developers.facebook.com/docs/authentication/permissions/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文