![]() ESN 47571-090123-392845-18 |
|
Document Name: Fetching RSS info with the Awareness API Document Description: Fetching RSS info with the Awareness API2009/01/23 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 Aareness 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: <H1>Unauthorized</H1> <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" />
</feed>
</rsp>
<?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"
uri="SiteNewsForAplawrenceUnixLinuxAndMacOsXResources">
<entry date="2009-01-22" circulation="0" hits="0" reach="53" />
</feed>
</rsp>
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.
#!/usr/bin/perl
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) {
$id=$_;
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;
next;
}
@stuff=split /\n/, $response->content;
foreach (@stuff) {
next if not /circulation=/;
$count= $_;
$count=~s/.*circulation=\"//;
$count=~s/" hits.*//;
$total += $count;
print "$id $count\n";
}
}
print "Total $total\n";
Author: Anthony Lawrence - Contact Author Publisher: Anthony Lawrence Licensee Name: Anthony Lawrence Reference URL: http://aplawrence.com/Web/awareness_api.html Copyright: All Rights Reserved Registration Date: 1/23/2009 7:37:04 PM UTC Views: 169 |
