=head1 NAME

REST::Google::Search - OO interface to Google Search API


	use REST::Google::Search;


	my $res = REST::Google::Search->new(
		q => 'Larry Wall',

	die "response status failure" if $res->responseStatus != 200;

	my $data = $res->responseData;

	my $cursor = $data->cursor;
	my $pages = $cursor->pages;

	printf "current page index: %s\n", $cursor->currentPageIndex;
	printf "estimated result count: %s\n", $cursor->estimatedResultCount;

	my @results = $data->results;

	foreach my $r (@results) {
		printf "\n";
		printf "title: %s\n", $r->title;
		printf "url: %s\n", $r->url;


C<REST::Google::Search> provides OO interface to Google REST (aka AJAX) API for searching.

=head1 METHODS


=item __PACKAGE__->service()

Get/set service to use.

The following table lists the URL used to access Google search services:

	service   address
	-------   ------------------------------------------------------
	WEB       http://ajax.googleapis.com/ajax/services/search/web
	VIDEO     http://ajax.googleapis.com/ajax/services/search/video
	NEWS      http://ajax.googleapis.com/ajax/services/search/news
	LOCAL     http://ajax.googleapis.com/ajax/services/search/local
	IMAGES    http://ajax.googleapis.com/ajax/services/search/images
	BOOKS     http://ajax.googleapis.com/ajax/services/search/books
	BLOGS     http://ajax.googleapis.com/ajax/services/search/blogs
	PATENT     http://ajax.googleapis.com/ajax/services/search/patent

Service constants are exported on demand, so you can use the constants instead
of service URLs:

	use REST::Google::Search qw/VIDEO/;
	REST::Google::Search->service( VIDEO );

Default service is C<WEB>.

=item __PACKAGE__->http_referer()

Get/set HTTP C<Referer> header.

I<Note:> Google says that you should supply a valid HTTP referer header each time you
perform a request to their AJAX API, so C<new()> raises warning unless referer is specified.

=item __PACKAGE__->new()

The constructor use it's arguments to build a valid HTTP GET request to Google Search service,
so it takes the same arguments as the web service takes. Please refer to 'Google Search AJAX API'
documentation for complete list of arguments for Google Search. E.g.:

	my $res = REST::Google::Search->new(
		q => 'Pamela Anderson',
		start => 4,
		hl => 'fr'

If you're using the default (WEB) search, the code above will perform a following HTTP GET request:


I<Note:> You can left protocol version number unspecified while making your searches since
C<v=1.0> is passed by default.


=head1 CLASSES

C<REST::Google::Search> contains dedicated classes for each of supported search services. You may
use them instead of specifying certain service with C<service> class method. E.g:

	use REST::Google::Search::Blogs;
	# ...
	# set referer, etc
	my $r = REST::Google::Search::Blogs->new( q => 'foobar' );

is the same as:

	use REST::Google::Search qw/BLOGS/;
	REST::Google::Search->service( BLOGS );
	# ...
	# set referer, etc
	my $r = REST::Google::Search->new( q => 'foobar' );

Available classes:


=item L<REST::Google::Search::Web>

=item L<REST::Google::Search::Blogs>

=item L<REST::Google::Search::Books>

=item L<REST::Google::Search::Images>

=item L<REST::Google::Search::Local>

=item L<REST::Google::Search::Video>

=item L<REST::Google::Search::News>

=item L<REST::Google::Search::Patent>


=head1 SEE ALSO

L<REST::Google> - the base class for this module;

L<http://code.google.com/apis/ajaxsearch/documentation/#fonje> - brief information about
Google Search AJAX API in non-Javascript environments;

L<http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje> - Google Search AJAX API documentation;

L<Google::Search> - high-level class for Google Search 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.