我正在尝试编写脚本以在管理员离线时发布到页面。我的应用程序具有管理员用户的 manage_pages 扩展权限。这是我的代码:
require('php-sdk/src/facebook.php');
$facebook = new Facebook(array(
'appId' => 'MY_APP_ID', // YOUR APP ID
'secret' => 'MY_SECRET', // YOUR API SECRET
'cookie' => true
));
$user_admin_id = 'MY_ADMIN_ID';
$page_id = 'MY_PAGE_ID';
//get the access token to post to my page via the graph api
$accounts = $facebook->api("/" . $user_admin_id . "/accounts");
foreach ($accounts['data'] as $account)
{
if ($account['id'] == $page_id)
{
//found the access token, now we can break out of the loop
$page_access_token = $account['access_token'];
break;
}
}
但我总是收到这条消息:
“致命错误:未捕获的 OAuthException:请求此资源需要用户访问令牌。在第 1033 行的 /home/itrade10/public_html/khodiersoftware/php-sdk/src/base_facebook.php 中抛出”