使用API Graph发布到Facebook墙上,却找不到分享按钮

4

在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);

功能正常,但分享按钮缺失。有评论和点赞按钮,但没有分享按钮。请不要给我任何教程或Facebook文档的链接。如果你知道如何解决这个问题,或者知道它不可能实现,请直接告诉我。谢谢!

2个回答

6

好的,我找到了解决方案。也许有人会感兴趣。要添加带分享按钮的链接,您需要使用“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
);

不幸的是,这并不是完全替代方案,因为Facebook在使用此方法时忽略了描述、标题和图片参数。如果您有兴趣看到这个问题得到解决,请订阅错误报告:https://developers.facebook.com/bugs/194522957295380 - Tom
这段代码是否有分享链接到朋友动态的选项 $result = $facebook->api( 'me/links', 'post', $attachment ); 而不是使用朋友的 ID... - Warrior

0
请注意,使用/links而不是/feed也适用于在Facebook页面上发布到墙上 - 如果您使用/feed,则没有共享按钮(链接),如果您使用/links,则会出现。 Facebook API文档位于“发布”部分here。对于那些感兴趣的人,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)

希望这对某人有所帮助....


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接