» » » You are reading »

How to Get Facebook Page Like Count Without Access Token


This code had been deprecated, follow this link for a more updated code.

facebook-count-php
Facebook had change their API flow to work with apps. Previous PHP code to acquire your Facebook page like count might not work anymore. The API needed access token or auth configuration of an apps for it to GET the like count of your Facebook page. Here’s a simple PHP snippet for you to get Facebook page like count without access token. Copy or add this to your custom functions.

<?php
function dez_get_the_fb_like( $fb_pagename = '' ) {
$fburl = 'https://www.facebook.com/'. $fb_pagename;
$params = 'select like_count from link_stat where url = "'.$fburl.'"';
$component = urlencode( $params );
$urls = 'http://graph.facebook.com/fql?q='.$component;
$string = file_get_contents( $urls );
if( $string ) {
 $fbLIkeAndSahre = json_decode( $string );
 $getFbStatus = $fbLIkeAndSahre->data['0'];
 $likecount = $getFbStatus->like_count;
 return $likecount;
} else {
 return 'Data did not exist';
}
}
?>

and use this any where in your templates or php application.

<?php
echo dez_get_the_fb_like( $fb_pagename = 'YOUR PAGE NAME NOT ID' );
?>

Check this free WordPress plugin that have built-in social counter widgets.

How to Get Facebook Page Like Count Without Access Tokenhttp://cdn.dezzain.com/1/2015/12/facebook-count-php.jpghttp://cdn.dezzain.com/1/2015/12/facebook-count-php-300x300.jpgRichie KS SnippetsTutorialsFacebook,php coding
The Facebook API needed access token to GET the like count of your Facebook page. Here's a simple PHP snippet for you to get it without access token.

2 Comments Already

  1. Thanks Bro

    Public CommentUserThanks Bro
  2. thanks so much.
    working like a charm.

    is this possible for instagram, too?

    Public CommentUserthanks so much. working like a charm. is this possible for instagram, too?

Leave a Reply

Your email address will not be published. Required fields are marked *