使用API​​图形和缺少共享按钮发布到Facebook墙

问题描述

| 是否可以在Graph API中使用共享按钮发布消息。我使用SDK-PHP v3和以下代码
    $args = array(
        \'access_token\' => TOKEN_HERE,\'message\'   => \'message here\',\'link\'      => \'http://www.example.com/\',\'caption\'   => \'caption here\'
    );
    $result = $facebook->api(\"/me/Feed\",\"post\",$args);
它工作正常,但缺少共享按钮。有评论和赞按钮,但没有SHARE按钮。请不要给我任何指向教程或fecebook文档的链接。如果您知道该怎么做,或者您知道不可能,请编写它。谢谢!     

解决方法

好的,我找到了解决方案。也许有人会感兴趣。要使用共享按钮添加链接,您必须使用\'me / links \'而不是\'me / feed \'。
$attachment = array(
    \'access_token\'=>TOKEN_HERE,\'message\'=>\'message_here\',\'link\' => \'http://www.example.com/\',);

$result = $facebook->api(
    \'me/links\',\'post\',$attachment
);
    ,请注意,使用/ links代替/ feed也适用于在Facebook页面上发布到墙上-如果使用/ feed,则共享按钮(链接)不存在,如果使用/ links,则显示共享按钮(链接)。 Facebook API文档在此处的“发布”部分中。对于那些感兴趣的人,Ruby / Rails看起来像这样:
   ## Put together the content of the post to the FB page 
   data = {
      :message      => \'Your message here\',:link         => \'http://www.example.com/your/own/page/link/here\',:picture      => \'http://www.example.com/your/own/image/link/here\',:name         => \'Your post name or title here\',:caption      => \'Your caption here\',:description  => \'Your description here\'    
    }
    ## Start a new HTTPClient
    client = HTTPClient.new()
    ## Define the URI for posting to Facebook
    url = \'https://graph.facebook.com/<FB PAGE ID HERE>/links?access_token=<FB PAGE ACCESS TOKEN HERE>\'
    ## POST the message to Facebook
    msgpost = client.post(url,data)
    ## Get the results of the post (in JSON)
    msgpostresults = JSON.parse(msgpost.body)
希望对某人有所帮助。