如何在Facebook上共享外部链接或URL

问题描述

| 我需要编写将发送链接到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
    );
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...