i think facebook changed api. few days ago code stopped working. used following code read number of likes of fb page:
<?php $link = "http://graph.facebook.com/pagename"; $json = file_get_contents($link); $json = json_decode($json); ?> <div class="fb_likes"> <p><?hp echo $json->{'likes'}; ?> does know has changed , how can read number of likes now?
thanks
you may retrieve fb count function below:
function facebook_count($url){ $fql = "select share_count, like_count, comment_count "; $fql .= " link_stat url = '$url'"; $fqlurl = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql); $response = file_get_contents($fqlurl); return json_decode($response); } $fb = facebook_count('https://www.facebook.com/pages/coca-cola/1517438451865061'); echo $fb[0]->like_count;
Comments
Post a Comment