APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Fetching RSS info with the Awareness API

© January 2009 Anthony Lawrence

Most bloggers have one RSS feed per blog - that's usually because their blogging software only lets them create either a full feed (complete article text) or an "excerpt" feed (just a paragraph or two from each post). I've talked before about how it's better if you can offer both. I do offer both, but I also offer a number of other choices for those who are only interested in certain sections of the site.

I do that because it's easy enough for me to do: I create my own RSS feeds and adding another is trivial. What's NOT trivial is keeping track of them. I really don't want to log in to the Google Feedburner site just to see what's going on. I am particularly interested in what the total subscriber count is and I'm far too lazy to go look up the individual stats and add them up. That's what code is for, isn't it?

The Google Awareness API is supposed to help you do that. Unfortunately it's a little broken right now, but I'll present the code in the hope that they will be fixing it soon.

Notes: I wrote this on Mac OS X in Perl but my first try failed because LWP couldn't do https. You need to have Crypt::SSLeay for that. If you don't have that, you can get it with "cpan Crypt::SSLeay" but you need to have the OS X development tools installed (but why would you NOT have them installed, I ask?).

What this code does is go get your basic stats for a feed. You need to have enabled that (it's under the "Publicize" tab). If you have not enabled it, you'll get back this:

<H2>Error 401</H2>

As I mentioned above, unfortunately you don't get anything useful back right now even if you have enabled it. Here's a feed of mine that actually has over 450 subscribers but the Awareness API says it has none:

<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <!--This information is part of the FeedBurner Awareness
  API. If you want to hide this information, you may do so
  via your FeedBurner Account.-->
  <feed id="qo08rlkd5s8kaahnm0ilh61v1c" uri="aplawrence/FOND">
    <entry date="2009-01-22" circulation="0" hits="0" reach="53" />

<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
  <!--This information is part of the FeedBurner Awareness
  API. If you want to hide this information, you may do so
  via your FeedBurner Account.-->
  <feed id="616b6ktmbbms8iibsmf3e8ki58"
    <entry date="2009-01-22" circulation="0" hits="0" reach="53" />

It's mildly interesting that it manages to have some "reach" with zero circulation, isn't it? Oh, well, I'm sure that will get fixed. When it does. the code will work a bit better. Right now it just prints 0 for all sites.

use LWP;
my $browser = LWP::UserAgent->new;
my @ids=qw(put your ids here separated by spaces);
# or you can use the urls instead (like "aplawrence/ZPYH") 
# and change "id=" to "uri=" below.
my $total=0;
foreach (@ids) {
  my $url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?id=" . $id;
  my $response = $browser->get( $url );
  if (not $response->is_success) {
  print STDERR "Can't get $url -- ", $response->status_line;
  @stuff=split /\n/, $response->content;
  foreach (@stuff) {
   next if not /circulation=/;
   $count= $_;
   $count=~s/" hits.*//;
   $total += $count;
   print "$id $count\n";
print "Total $total\n";

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> Fetching RSS info with the Awareness API


Inexpensive and informative Apple related e-books:

El Capitan: A Take Control Crash Course

Take Control of Apple Mail, Third Edition

Photos for Mac: A Take Control Crash Course

Digital Sharing Crash Course

Take Control of Parallels Desktop 12

More Articles by © Anthony Lawrence

Sat Jan 24 15:20:17 2009: 5240   TonyLawrence

Well - gosh! This morning the API is returning correct numbers. All fixed!

Tue Oct 6 11:30:12 2009: 7078   thelittlemermaid

doesn’t the feedburner awareness api give the time of the feed item i.e. time when post was published? I mean using the getitemdata method, alongwith the item title, item url and the circulation, hits, dates it should also give the time when the post was posted. Or is there a different way out where I can get the retrieve the time of item posting for feedburner feeds?

I tried out your fb_awareness_api_demo.phps and it worked to fetch the latest feeds. But what if I want to fetch the previous feed items data and also the time of posts published. Please tell me if you know a way out.


Tue Oct 6 13:44:35 2009: 7079   TonyLawrence

The API is described at (link) so you can read it for yourself. It has the dates for feed items, but I don't understand what you mean by "previous feed items data". If you mean something that has already passed out of the feed, then no, of course not.

Wed Oct 7 05:14:48 2009: 7083   thelittlemermaid


Thanks for replying.

What I mean is I want to access the archives of the particular blog. If you check out this code at (link) with the getitem data class, he is able to fetch the yesterdays ten results. Also he can pull the item title, url, date, itemviews and clickthroughs. My query is whether I can fetch the time when this particular item i.e post was posted on the blog??

Thanks once again.

Wed Oct 7 11:15:25 2009: 7086   TonyLawrence

The API page explains that If no date is specified, Yesterday's date is assumed. "Current" is always yesterday's data.

So, yes, you can get older data, but I'm sorry that I still don't understand what you want.


Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

The idea that Bill Gates has appeared like a knight in shining armour to lead all customers out of a mire of technological chaos neatly ignores the fact that it was he, by peddling second rate technology, led them into it in the first place, and continues to do so today. (Douglas Adams)

Linux posts

Troubleshooting posts

This post tagged:





Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode