【问题标题】:Post to facebook wall using API Graph and missing share button使用 API Graph 和缺少的分享按钮发布到 facebook 墙上
【发布时间】:2011-05-26 19:23:02
【问题描述】:

是否可以在 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);

它工作正常,但缺少分享按钮。有评论和点赞按钮,但没有分享按钮。请不要给我任何指向教程或 fecebook 文档的链接。如果您知道如何执行此操作,或者您知道这是不可能的,只需编写它即可。谢谢!

【问题讨论】:

    标签: facebook post button share


    【解决方案1】:

    好的,我找到了解决方案。也许有人会感兴趣。要添加带有分享按钮的链接,您必须使用“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 在使用此方法时会忽略描述、标题和图片参数。如果您有兴趣看到此修复,请订阅错误报告:developers.facebook.com/bugs/194522957295380
    • 他们是否可以选择使用此代码将链接分享给朋友提要 $result = $facebook->api( 'me/links', 'post', $attachment );而不是我使用朋友 id...
    【解决方案2】:

    请注意,使用 /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)
    

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

    【讨论】:

      猜你喜欢
      • 2013-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多