Back PHP

Grab Twitter, Feedburner and Delicious Count of your website with PHP

WRITTEN BY ON 17 Jan 2011
15,444 VIEWS • SHARES
6 comments

Get the stat of your website with this PHP script. It grab the total number of twitter followers, feedburner subscribers and also delicious bookmarks of your account/website.

PHP

Your webserver need to have SimpleXML and JSON supports. The output is stored in an array. What you have to do is to replace $username and $url variables to your own setting.

	//Grab Twitter
	$username = 'quenesswebblog';	/* Twitter username */
	$api_page = 'http://twitter.com/users/show/' . $username;
	$xml = file_get_contents ( $api_page );
	$profile = new SimpleXMLElement ( $xml );
	$count = $profile->followers_count;

	$data['twitter'] = $count;

	//Grab Feedburners
	$username = 'queness';	/* feedburner feed name */
	$api_page = 'https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . $username;
	$xml = file_get_contents ( $api_page );
	$profile = new SimpleXmlElement($xml, LIBXML_NOCDATA);
	$rsscount = (string) $profile->feed->entry['circulation'];

	$data['rss'] = $rsscount;	

	//Grab Delicious
	$url = 'www.queness.com';	/* url */
	$api_page = 'http://feeds.delicious.com/v2/json/urlinfo/data?url=%20www.queness.com';
	$json = file_get_contents ( $api_page );
	$json_output = json_decode($json, true);  

	$data['delicious'] = $json_output[0]['total_posts']; 


	print_r($data);
Join the discussion

Comments will be moderated and rel="nofollow" will be added to all links. You can wrap your coding with [code][/code] to make use of built-in syntax highlighter.

6 comments
dlv 14 years ago
Thanks Kevin for share this script !
A question, if you call this script to be load, which is the code to insert in our php page where we want to display the numbers ?

thanks, adeux!
Reply
Kevin Liew 14 years ago
You can use echo. In this case, it will be:

echo 'Twitter followers:' . $data['twitter'];
echo 'RSS subscriber:' . $data['rss'];
echo 'Delicious bookmarks:' . $data['delicious'];
Reply
dlv 14 years ago
thanks Kevin for your response ! now I understand !

have a nice day there
adeux!
Reply
Ayaz 14 years ago
Hey, i just tried it , it works fine but the rss readers count shows 0 , while i have 1700+ readers, i have double checked the username
Reply
Kevin Liew 14 years ago
You can try to enter the feedburner api to the browser, it should return a blank page, but if you view source, you will able to see the xml string. Just to make sure it returns data. Then you can start debug it accordingly.

https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=queness
Reply
Ayaz 14 years ago
k thx, it started working on its own somehow
Reply