我正在尝试实现一项功能,以从 Symfony 2 框架的管理页面 (SonataAdminBundle) 将帖子发布到 Facebook 粉丝页面。我已经集成了 Facebook PHP SDK,并且在 Controller 中尝试使用它:
$facebook = new \Facebook(array(
'appId' => $myAppId,
'secret' => $myAppSecret,
'cookie' => false,
));
//Get App Token
$token = $facebook->getAccessToken();
//Try to Publish on wall or catch the Facebook exception
try {
$args = array('access_token' => $token,
'from' => $myAppId,
'link' => 'http://mypage.pl',
'name' => 'My Page',
'caption' => $object->getTitle() ,
'description' => 'Description....',
'message' => $object->getText(),
);
$result = $facebook->api('/'.'$myAppId'.'/feed/', 'POST', $args);
}
//If the post is not published, print error details
catch (FacebookApiException $e) {
....
));
}
我想我收到了一个带有 app id 和 post id 的响应,如下所示:
{"status":"OK","content":{"id":"295131140562739_359030107506176"}}
但该帖子并未显示在 Facebook 粉丝专页时间线上。有人成功实施了吗?