Posts Tagged ‘subscribers’

Display A Text Version Of Your Feedburner Subscribers

All credit for this goes to hongkiat.com, I’m simply re-posting because I find this to be extremely useful, and like to note stuff like this on my own blog.

Although recognizable, the Feedburner chicklet that displays the number of subscribers is ehh.  I’d much rather be able to stylize the number itself and fit it into my own design.  Wouldn’t it be nice if you can pull the number out of the chicklet and do whatever you want?  You can, and it’s extremely easy!  You can see I just implemented this on the sidebar on Carbon Fiber Gear:

subscribe-text

Of course that number can be styled however you want it using CSS.  So how do you get it?  Simply put this code somewhere in your WordPress template (Mine is in sidebar.php), and make sure to replace the “feedburnerid” with your ID in the $whaturl line:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?
	//get cool feedburner count
	$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburnerid";
 
	//Initialize the Curl session
	$ch = curl_init();
 
	//Set curl to return the data instead of printing it to the browser.
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
	//Set the URL
	curl_setopt($ch, CURLOPT_URL, $whaturl);
 
	//Execute the fetch
	$data = curl_exec($ch);
 
	//Close the connection
	curl_close($ch);
	$xml = new SimpleXMLElement($data);
	$fb = $xml->feed->entry['circulation'];
	//end get cool feedburner count
 
	// Use $fb to print out the number of subscribers
	echo 'Join the <i>' . $fb . '</i> subscribers';
?>

You’ll need to make sure the feed count service is activated. To do that, login to your Feedburner account, hit the “Publicize” tab, and then go to to Feed Count. On this page you’ll need to activate the service. There you have it!