Calculate number of fb like of a node

Created on 24 June 2013, over 11 years ago
Updated 11 November 2024, about 1 month ago
/***
 *For count for facebook like of particular node , you may further calculate for other requirements.
   But it is little bit slow
***/
        //-------------------- 1st method -----------------------//
$nod = 2; // node id
//$alias_val = drupal_get_path_alias($path = $_GET['q'], $path_language = NULL);
$alias_val = drupal_get_path_alias($path = 'node/'.$nod, $path_language = NULL);
$fql = "SELECT like_count FROM link_stat WHERE url ='".$base_url."/".$alias_val."'";

$jdata = json_decode(file_get_contents('https://api.facebook.com/method/fql.query?format=json&query=' . urlencode($fql)), true);

$tot_like = $jdata[0]['like_count'];


       //  --------------2nd method----------- //

$alias_val = drupal_get_path_alias($path = 'node/'.$nod, $path_language = NULL);
$furl = $base_url."/".$alias_val;
$jdata = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".$furl;
$xmlinfo = simplexml_load_file($jdata);
$tot_like = $xmlinfo->link_stat->total_count;

    //-------------------- 3rd method ------------------------//

$url = 'http://example.com/home-page';
$jdata = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".$url;

$xmlinfo = drupal_http_request($jdata);
$fresult = explode(" ",$xmlinfo->data);
if($fresult[25]>0) {
$tot_like = $fresult[25];


💬 Support request
Status

Closed: outdated

Version

2.2

Component

Miscellaneous

Created by

🇮🇳India gaurishankar Delhi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024