【问题标题】:Add an Album to Page using API (php)使用 API (php) 将相册添加到页面
【发布时间】:2011-09-15 13:19:54
【问题描述】:

我正在尝试为页面创建相册,但出现以下错误;

[2011 年 9 月 15 日 22:38:14] PHP 致命错误:未捕获的 OAuthException:(#100) 专辑所有者的 ID 无效 在第 988 行的 C:\inetpub\wwwroot\Diveengine\v3\facebook\base_facebook.php 中抛出

代码如下

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'];

我已经能够为我的个人资料创建一个相册,但是我想要这个页面。

【问题讨论】:

    标签: php facebook-graph-api


    【解决方案1】:

    好的,伙计,花了很长时间才弄清楚这一点,但是就这样吧。您的代码可能没问题,但诀窍是获得正确的访问令牌。最初,我认为我必须创建一个页面访问令牌(使用图形 api 资源管理器),其中包含所有可以让我做我想做的事的装饰。

    事实证明,你需要做的就是:

    1) 转到https://developers.facebook.com/tools/explorer 2) 它可能会自动填充您的 facebook id,但在末尾添加 /accounts,所以它看起来像这样:

    #yourfacebookidnumber/帐户

    或者您可以将其更改为

    https://graph.facebook.com/me/accounts

    您将获得一个 JSON 转储,其中包含您作为管理员的所有粉丝页面的列表。找到您要发布到的粉丝页面(您需要成为该粉丝页面的管理员)。

    获取那里指定的访问令牌,在您的代码中使用它,Bob 就是您的叔叔!

    【讨论】:

    • 感谢终于搞定了如何获取页面的访问令牌。
    • 这告诉我“请求此资源需要访问令牌”:(对此有什么新想法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-31
    • 1970-01-01
    • 2013-05-25
    • 2012-06-20
    • 2013-08-26
    相关资源
    最近更新 更多