Display your RSS feed count in plain text

This tutorial will show you how to display your Feedburner feed count as a plain text. A good example is shown by Smashing Magazine’s feed count.

Display feed count as plain text

The Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=your-feed";
 
//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
?>

You need to replace “your-feed” (3rd row) with your feed url

Now to display your feed count anywhere just echo the $fb variable like this :

1
    <?php echo $fb;?>

Source : 45n5.com


Bookmark and Share

Tutorial Stats : 626 views
Rate Tutorial :
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, Rating: 5

3 responses so far, want to say something?

  1. Display your RSS feed count in plain text | CrazyLeaf Design Blog says:

    [...] Read this tutorial and get the PHP code @ CLD Tutorials Posted in : Programming Post statistics : 1 views [...]

  2. Kevin says:

    Nice example of using CURL with PHP. I was struggling to display rss data of the object return by curl. This example helped me to make it working… Nice work.

  3. Prabhath says:

    Great work mate…really helped me your tutorial.
    Thanks

Leave a Reply

Join our Flickr Group
Think Pink Bookmark (See link for pattern and how to customize your own)ShOoTborn dyingRetro Type treatmentPink Rings and Things - for Breast Cancer Awareness Month, 2008Mimi gives you a Texas-sized hello (before I go pick up kids from school)radioprotest with umbrellasPlayfulFrom the admin of Think Pink for Breast Cancer AwarenessPlaying With TypographyPATRIOTIC IMAGE CHALLENGE using the word "Vote"!!! - not a contest - Post entries below. Get patriotic, America!!!! (and I hear Canada has an election coming up, too...so inviting members from that country)