REST::Google::Feeds - OO interface to Google Feeds API
use REST::Google::Feeds; REST::Google::Feeds->http_referer('http://example.com'); my $res = REST::Google::Feeds->new('http://digg.com/rss/index.xml'); die "response status failure" if $res->responseStatus != 200; my $feed = $res->responseData->feed; printf "title: %s\n", $feed->title; printf "link: %s\n", $feed->link; printf "description: %s\n", $feed->description; foreach my $e ( $feed->entries ) { printf "\n"; printf "title: %s\n", $e->title; printf "link: %s\n", $e->link; printf "date published: %s\n", $e->publishedDate; }
REST::Google::Feeds provides OO interface to Google REST (aka AJAX) API for feeds.
REST::Google::Feeds
Get/set HTTP Referer header.
Referer
Note: Google says that you should supply a valid HTTP referer header each time you perform a request to their AJAX API, so new() raises warning unless referer is specified.
new()
q argument should contain URL to a valid RSS or Atom feed. Please refer to 'Google Feeds AJAX API' documentation for complete list of arguments for Google Feeds service. E.g.:
q
my $res = REST::Google::Feeds->new( q => 'http://digg.com/rss/index.xml', );
The code above will perform a following HTTP GET request:
http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fdigg.com%2Frss%2Findex.xml&v=1.0
Note: You can left protocol version number unspecified while making your searches since v=1.0 is passed by default.
v=1.0
See REST::Google new method.
new
Method returns REST::Google::Feeds::Data object, which has a single method feed.
REST::Google::Feeds::Data
feed
my $res = REST::Google::Feeds->new( q => 'http://digg.com/rss/index.xml', ); my $feed = $res->responseData->feed;
Method returns REST::Google::Feeds::Feed object, which has accessors for all incapsulated data.
REST::Google::Feeds::Feed
my $feed = $res->responseData->feed; print $feed->title; print $feed->link;
Attributes of $feed are:
$feed
title link author description type entries
Obtaining feed entries:
foreach my $entry ($feed->entries) { print $entry->title; }
Attributes of $entry are:
$entry
title link author publishedDate contentSnippet content categories
REST::Google - the base class for this module
http://code.google.com/apis/ajaxfeeds/documentation/#fonje - Google Feeds AJAX API
Copyright 2008, Eugen Sobchenko <ejs@cpan.org> and Sergey Sinkovskiy <glorybox@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install REST::Google, copy and paste the appropriate command in to your terminal.
cpanm
cpanm REST::Google
CPAN shell
perl -MCPAN -e shell install REST::Google
For more information on module installation, please visit the detailed CPAN module installation guide.