问题描述
|
我需要编写将发送链接到Facebook Fanpage墙的应用程序。
我使用的是PHP SDK v3。有一个示例如何发布内容:
require \'facebook.php\';
$facebook = new Facebook(array(
\'appId\' => \'XXXX\',\'secret\' => \'YYYYYYYYYY\',\'cookie\' => true,));
$fbsession = $facebook->getSession();
if ($fbsession) {
$attachment = array(
\'message\' => \'this is my message\',\'name\' => \'This is my demo Facebook application!\',\'caption\' => \"Caption of the Post\",\'link\' => \'http://www.lycos.com\',\'description\' => \'Test de post depuis application PHP\',\'picture\' => \'http://www.lalibre.be/img/logoLaLibre.gif\',\'actions\' => array(array(\'name\' => \'Get Search\',\'link\' => \'http://www.google.com\'))
);
$result = $facebook->api(\'/USER_WALL/feed/\',\'post\',$attachment);
}
而且效果很好。问题是我只想发布普通的Facebook链接(带有链接图标,没有应用程序名称和“共享”按钮)
像这样的东西:
$result = $facebook->api(\'/USER_WALL/feed/\',\'link\',$attachment);
gives me an error (Fatal error: Uncaught Exception: Unsupported method,link thrown in /home/.../src/base_facebook.php on line 959)
任何想法如何做到这一点?
我找到了两个指向FB文档的链接:
http://developers.facebook.com/docs/reference/rest/links.post/
http://developers.facebook.com/docs/reference/api/link/
但我仍然不知道在PHP-SDK v3中使用它
http://developers.facebook.com/docs/reference/rest/links.post/
http://developers.facebook.com/docs/reference/api/link/
解决方法
在此网站上查看此示例。它是用户墙上状态更新和发布技术的完整实现。链接到教程
阅读评论后进行编辑
使用以下网址共享自定义链接:
http://www.facebook.com/sharer.php?u=http://www.YourUrlThatYouWantToShare.com
,解决了:
$attachment = array(
\'access_token\'=>TOKEN,\'message\'=>\'message_here\',\'link\' => \'http://www.example.com\',);
$result = $facebook->api(
\'me/links\',\'post\',$attachment
);