简体   繁体   中英

How to get the number of likes of a facebook link post using POST_ID/OBJECT_ID

i have an app that process input to jpeg and then post the link of the generated image to the user's timeline. now i want to get the number of likes of each post and echo it in a with another like button(linked with the same post). how can i do that? i used 'PHP SDK' when i post the image link(in another .php file). as much as possible i want to use the POST_ID or OJBECT_ID to access the facebook post. please give some some suggestions on what to use and how can i start. this is my first time to work with facebook apps.

all i have for now is this on the processor.php. i want the out put to be on the gallery.php. thanks in advance for any help.

processor.php

        if($user_id) {
          try {
            $ret_obj = $facebook->api('/me/feed', 'POST',
                                        array(
                                          'link' => $post_link,
                                          'message' => 'Posting with the PHP SDK!'
                                     ));
            echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';
            echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
          } catch(FacebookApiException $e) {

            $login_url = $facebook->getLoginUrl( array(
                           'scope' => 'publish_stream, read_stream'
                           )); 
            echo 'Please <a href="' . $login_url . '">login.</a>';
            error_log($e->getType());
            error_log($e->getMessage());
          }   
        } else {

          $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream, read_stream' ) );
          echo 'Please <a href="' . $login_url . '">login.</a>';

        } 

`

You get FB likes with

$likes    = $facebook->api("/".$POSTID."/likes");

This returns an array...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM