|
NAMEWebService::GData::Query - implements the core query parameters available in the google data API v2.SYNOPSISuse WebService::GData::Query; use WebService::GData::Constants qw(:format :query :general); my $query = new WebService::GData::Query(); $query->to_query_string();# by default:?alt=json&v=2&prettyprint=false&strict=true #?alt=jsonc&v=2&prettyprint=false&strict=true&start-index=1&max-results=10 $query->alt('jsonc')->limit(10,1)->to_query_string(); print $query->get('alt');#jsonc $query->v(1);#throw an error as only 2 is ok. $query->prettyprint(1);#throw an error as only 'true' or 'false' is possible. #use constants where you can $query->prettyprint(TRUE); $query->alt('json-c');#this is wrong $query->alt(JSONC);#ok! DESCRIPTIONinherits from WebService::GData.Google data API supports searching different services via a common set of parameters. Unfortunately, some services only handles a subset of this "core" parameters... You should read the service Query documentation to know exactly the available parameters. This package also implements some helpers functions to shorten up a little the parameter settings. In order to avoid to send uncorrect parameter values, the package checks for their validity and will throw a WebService::GData::Error object containing 'invalid_parameter_type' as the "code" and the name of the function as the "content". Checking the data before sending a request will avoid unnecessary network transactions and reduce the risk of reaching quota limitations in use for the service you are querying. WebService::GData::Constants contains predefined value that you can use to set the parameters. Using the constants can avoid typo errors or unnecessary code change when an update is available with a new value. CONSTRUCTORnewCreates a basic query instance. The following parameters
are set by default:
Parameters
Returns
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->to_query_string();# by default:?alt=json&v=2&prettyprint=false&strict=true GENERAL METHODSgetReturns the parameter specified.
The function uses the underscore nomenclature where the parameters use the hyphen nomenclature. You should change all the underscore to hyphen when accessing the value. Parameters
Return
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->get('alt');#json $query->get('published_min');#does not work... $query->get('published-min');#ok! to_query_string Concatene each parameter/value pair into a query string.
This function is also called in a string overload context.
"$instance" is the same as
$instance->to_query_string();
Parameters
Returns
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->to_query_string();#?alt=json&v=2&prettyprint=false&strict=true "$query"; #?alt=json&v=2&prettyprint=false&strict=true print $query; #?alt=json&v=2&prettyprint=false&strict=true PARAMETER METHODSAll the methods that set a parameter return the instance so that you can chain the function calls.Example: $query->alt(JSONC)->limit(10,1)->strict(TRUE)->prettyprint(FALSE)->to_query_string(); The following setters are available: strict If set to true (default), setting a parameter not
supported by a service will fail the request.
Parameters
Returns
Throws
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->strict('true'); $query->strict(TRUE);#better $query->strict('hello');#die fields Allows you to query partial data. This is a Google data
experimental feature as of this version.
Parameters
Returns
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->fields('id,entry(author)');#only get the id and the author in the entry tag See Also The reference for the partial queries: <http://code.google.com/intl/en/apis/gdata/docs/2.0/reference.html#PartialResponse> v Set the google Data API version number. Default to
WebService::GData::Constants::GDATA_MINIMUM_VERSION. You shoud not set this
unless you know what you do.
alt Specify the response format used. Default to
WebService::GData::Constants::JSON. You shoud not set this unless you know
what you do.
prettyprint If set to true (default false),the result from the
service will contain indentation.
Parameters
Returns
Throws
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->prettyprint('true'); $query->prettyprint(TRUE);#better $query->prettyprint('hello');#die author Specify the author of the contents you want to retrieve.
Each service derives the meaning for their own feed.
Parameters
Returns
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->author('GoogleDeveloper'); updated_min Retrieve the contents which update date is a minimum
equal to the one specified (inclusive). Note that you should retrieve the
value as 'updated-min' when used with WebService::GData::Query::get().
Parameters
Returns
Throws
updated_max Retrieve the contents which update date is at maximum
equal to the one specified (exclusive). Note that you should retrieve the
value as 'updated-max' when used with WebService::GData::Query::get().
Parameters
Returns
Throws
published_min Retrieve the contents which publish date is a minimum
equal to the one specified (inclusive). Note that you should retrieve the
value as 'published-min' when used with
WebService::GData::Query::get().
Parameters
Returns
Throws
published_max Retrieve the contents which publish date is a maximum
equal to the one specified (exclusive). Note that you should retrieve the
value as 'published-max' when used with
WebService::GData::Query::get().
Parameters
Returns
Throws
start_index Retrieve the contents starting from a certain result.
Start from 1. Setting 0 will revert to 1. Note that you should retrieve the
value as 'start-index' when used with WebService::GData::Query::get().
Parameters
Returns
max_results Retrieve the contents up to a certain amount of entry
(Most of the services set it to 25 by default).
Note that you should retrieve the value as 'max-results' when used with WebService::GData::Query::get(). Parameters
Returns
limit An extension that allows you to set start_index and
max_results in one method call: get('limit') will return undef. Follow the
same coercicion logic of start_index and max_results.
Parameters
Returns
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->limit(10,5); #equivalent to $query->max_results(10)->start_index(5); q Insensitive freewords search where:
Parameters
Returns
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->q('"exact phrase" snowbaord sports -ski'); category Allow to narrow down the result to specifics categories.
Parameters
Returns
Example: use WebService::GData::Query; my $query = new WebService::GData::Query(); $query->category('-Shows,Entertainment|Sports'); SEE ALSODocumentation of the parameters:<http://code.google.com/intl/en/apis/gdata/docs/2.0/reference.html#Queries> BUGS AND LIMITATIONSIf you do me the favor to _use_ this module and find a bug, please email me i will try to do my best to fix it (patches welcome)!AUTHORshiriru <shirirulestheworld[arobas]gmail.com>LICENSE AND COPYRIGHTThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |