我正在尝试将动态数据发布到 facebook 墙上。
我为 php 下载了 facebook api。
首先,至于测试,我使用下面的代码。
<?php
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require '../src/facebook.php';
$config = array(
'appId' => 'myAPPID',
'secret' => 'MySecretCode'
);
//'access_token' => $access_token = $facebook->getAccessToken(),
$facebook = new Facebook($config);
$attachment = array(
'access_token' => 'my_tokenkey',
'message' => 'Test Message offline test message',
'name' => 'Name Test offline test...',
'description' => 'here goes description and links http:anotherfeed.com | http://facebook.com/anotherfeed',
'caption' => 'this is caption for action link',
'picture' => 'http://www.google.com/tv/images/slivetv.png',
'link' => 'www.yahoo.com',
'properties' => array(
array('text' => 'test link 1', 'href' => 'http://anotherfeed.com/?ref=1'),
array('text' => 'test link 1', 'href' => 'http://anotherfeed.com/?ref=1'),
),
);
try {
$facebook->api('/me/feed', 'POST', $attachment);
} catch(FacebookApiException $e) {
echo $e;
# handling facebook api exception if something went wrong
}
?>
至于我的程序要求,我希望我的程序将数据发布到 facebook 的墙上,无论 facebook 是在线还是离线。
但是当我尝试这段代码时,我得到了错误。
OAuthException: An active access token must be used to query information about the current user.
有人可以给我建议吗?