Facebook Twitter and Google Plus Fan Counts PHP
The Facebook, Twitter and Google plus data are available publicly in Json format, we can use some information to easily display number of likes, followers and circle counts in plain text. I wanted to include Feedburner Subscriber count code too, but too bad Google has decided to put an end to Awareness API, without it we can not display subscriber count in plain text. The URLs in box below are three magic URLs from these top sites, which contains information about people and pages in JSON format. [cc lang=”html”] http://api.twitter.com/1/users/show.json?screen_name=‘; echo ‘Facebook Fans : ‘. $facebook_data->likes.’
‘; echo ‘Google Page Circle : ‘. $google_data->plusOneCount; echo ‘
'; //print_r($twitter_data); //print_r($facebook_data); //print_r($google_data); echo '‘; function get_data($json_url=”,$use_curl=false) { if($use_curl) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $json_url); $json_data = curl_exec($ch); curl_close($ch); return json_decode($json_data); } else { $json_data = file_get_contents($json_url); return json_decode($json_data); } } ?> [/cc]