Post to facebook wall using API Graph and missing share button

前端 未结 2 1359
臣服心动
臣服心动 2020-12-17 05:08

Is it possible to post a message with share button in Graph API. I use SDK-PHP v3 and this code:

    $args = array(
        \'access_token\' => TOKEN_HERE         


        
相关标签:
2条回答
  • 2020-12-17 05:34

    Note that using /links instead of /feed also applies to posting to the wall on a Facebook page - a share button (link) isn't there if you use /feed and does appear if you use /links. The Facebook API documentation is in the "Publishing" section here. For those interested, the Ruby/Rails looks something like this:

       ## 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)
    

    Hope that's some help to someone....

    0 讨论(0)
  • 2020-12-17 05:44

    ok, I found solution. maybe someone will be interested. to add a link with share button you have to use 'me/links' instead of 'me/feed'.

    $attachment = array(
        'access_token'=>TOKEN_HERE,
        'message'=>'message_here',
        'link' => 'http://www.example.com/',
    );
    
    $result = $facebook->api(
        'me/links',
        'post',
        $attachment
    );
    
    0 讨论(0)
提交回复
热议问题