简体   繁体   English

上传照片时,Facebook API错误“无效的相册ID”

[英]Facebook API error 'invalid album id' when uploading a photo

I want to add a large picture to a fan page that I just created. 我想在刚创建的粉丝页面中添加大图片。

This code works : 此代码有效:

$picUrl = 'http://myurl/test.jpg';
$photoId = $facebook->api("/me/photos","POST",array('url'=>$picUrl,'message'=>"status message","access_token"=>$token));

But this one doesn't work : 但这不起作用:

$picUrl = 'http://myurl/test.jpg';
$photoId = $facebook->api("/MYALBUMID/photos","POST",array('url'=>$picUrl,'message'=>"status message","access_token"=>$token));

I got this: 我懂了:

Fatal error: Uncaught OAuthException: (#120) Invalid album id 致命错误:未捕获的OAuthException:(#120)无效的相册ID

I have search a lot on other thread. 我在其他线程上搜索了很多。 I think its about the token. 我认为这与令牌有关。 But the token seems to work because I can post with feed/links on my fan page... 但是令牌似乎起作用了,因为我可以在粉丝页面上发布Feed /链接了...

Do you know what's wrong? 你知道怎么了吗 :) :)

Thanks a lot ! 非常感谢 !

The access_token generated to manage a user is not the same as the access_token needed to manage a page. access_token生成来管理用户是不一样access_token管理页面需要。

To get an access token for a page: 要获取页面的访问令牌:

me/accounts?fields=access_token,name

Then, use the page access token to run the query: 然后,使用页面访问令牌运行查询:

$facebook->api("/MYALBUMID/photos","POST",
                array('url'=>$picUrl,'message'=>"status message","access_token"=>$token));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM