| REST-Google documentation | view source | Contained in the REST-Google distribution. |
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.
Get/set HTTP Referer header.
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.
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.:
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.
See REST::Google new method.
Method returns REST::Google::Feeds::Data object, which has a single method 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.
my $feed = $res->responseData->feed; print $feed->title; print $feed->link;
Attributes of $feed are:
title link author description type entries
Obtaining feed entries:
foreach my $entry ($feed->entries) {
print $entry->title;
}
Attributes of $entry are:
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.
| REST-Google documentation | view source | Contained in the REST-Google distribution. |