| PX-API documentation | view source | Contained in the PX-API distribution. |
PX::API::Response - A Peekshows Web Services API response.
use PX::API;
my $px = PX::API->new({
api_key => '13243432434', #Your api key
secret => 's33cr3tttt', #Your api secret
});
my $response = $px->call('px.test.echo',{
arg1 => 'val1',
arg2 => 'val2',
});
A response object from the Peekshows Web Services API. PX::API::Response
is a subclass of HTTP::Response allowing for access to any response
parameters. Module::Pluggable::Object is used to allow an extensible
'plugin' style method for loading response modules.
Along with the response parameters available from HTTP::Response,
the following parameters are added for API responses.
successSet to a 1 or 0 to signify response success or error respectively.
responseThe actual content of the response returned from the API call.
err_codeThe error code returned from the API call, if an error occurred.
err_stringA description of the error returned from the API call, if an error occurred.
A response plugin is simply a module that transforms the API response
format into a usable perl object. Obviously this is not always necessary
and the original structure is always available via $response-{_content}>.
Response plugins are required to have to following methods available via its public api:
format()The format() method is used by PX::API::Response to match a plugin
with the format argument sent to the Peekshows API. This method simply
needs to return the name of the plugin format. ie: 'rest', 'json'
parse($content)The parse() method is called upon completion of an API call and is
passed the _content returned from the call. This method need only
return the perl object which was created from parsing the content.
Anthony Decena <anthony@1bci.com>
Copyright (c) 2007, Anthony Decena <anthony@1bci.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
| PX-API documentation | view source | Contained in the PX-API distribution. |