我正在尝试为页面创建相册,但出现以下错误;
[2011 年 9 月 15 日 22:38:14] PHP fatal error :未捕获的 OAuthException:(#100) 相册所有者 ID 无效 扔在 C:\inetpub\wwwroot\Diveengine\v3\facebook\base_facebook.php 第 988 行
代码如下
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => "aaaaaaaaaaaa",
'secret' => "aaaaaaaaaaaaaaaaaaaaa",
));
$facebook->setAccessToken("aaaaaaaaaaaaaaaaaaaaa");
$me = $facebook->api('/me');
//At the time of writing it is necessary to enable upload support in the Facebook SDK, you do this with the line:
$facebook->setFileUploadSupport(true);
//Create an album
$album_details = array(
'message'=> 'test album',
'name'=> 'Test Album'
);
$create_album = $facebook->api('/pageid/albums', 'post', $album_details);
// I have the page ID
//Get album ID of the album you've just created
$album_uid = $create_album['id'];
我已经能够为我的个人资料创建相册,但我希望在页面上创建相册。
最佳答案
好吧,伙计,我花了很长时间才弄清楚这一点,但现在就到这里了。您的代码可能没问题,但关键是获取正确的访问 token 。最初,我认为我必须创建一个页面访问 token (使用 graph api explorer)以及所有允许我做我想做的事情的装饰。
事实证明,您需要做的就是:
1) 转到 https://developers.facebook.com/tools/explorer 2) 它可能会自动填充您的 Facebook ID,但在末尾附加/accounts,这样它看起来像这样:
#yourfacebookidnumber/帐户
或者您可以将其更改为
https://graph.facebook.com/me/accounts
您将获得您作为管理员的所有粉丝页面列表的 JSON 转储。找到您要发布内容的粉丝页面(您需要是该粉丝页面的管理员)。
获取此处指定的访问 token ,在您的代码中使用它,Bob 就是您的叔叔!
关于php - 使用 API (php) 将相册添加到页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7431549/