NAME
eBay::API::Simple::JSON - Support for grabbing an RSS feed via API call
USAGE
my $api = eBay::API::Simple::JSON->new();
my $data = {
"user_eais_token" => "tim",
"body_text" => "mytext",
"foo" => "bar",
"greener_alt_topic" => "/green/api/v1/greenerAlternativeTopic/2/",
"items"=> [ {
"ebay_item_id"=> "250814913221",
"photo"=> "http=>//thumbs2.ebaystatic.com/m/m9X7sXOK303v4e_fgxm_-7w/140.jpg",
"price"=> 2.96,
"title"=> "TEST PUT - VAPUR 16 OZ FLEXIBLE FOLDABLE WATER BOTTLE BPA FREE"
} ],
"meta_title"=> "Foldable bottles can be stashed away when the water is gone",
"title"=> "TEST PUT - Foldable bottles can be stashed away when the water is gone"
};
$api->execute(
'http://localhost-django-vm.ebay.com/green/api/v1/greenerAlternative/',
$data
);
print $api->request_content() ."\n";
if ( $api->has_error() ) {
print "FAILED: " . $api->response_content();
#print "FAILED: " . $api->response_hash->{error_message} . "\n";
}
else {
print "SUCCESS!\n";
print $api->response_object->header('Location') . "\n";
}
my $hash = $call->response_hash();
# execution methods for "GET", "POST", "PUT", and "DELETE" requests
$api->get( $endpoint );
$api->post( $endpoint, data );
$api->put( $endpoint, $data );
$api->delete( $endpoint );
PUBLIC METHODS
new( { %options } }
my $call = ebay::API::Simple::JSON->new();
prepare( $url, $%args )
$call->prepare(
'http://sfbay.craigslist.org/search/sss',
{ query => 'shirt', format => 'rss', }
);
This method will construct the API request using the supplied URL.
Options
- $url (required)
-
Feed URL to fetch
- %$args (optional)
-
The supplied args will be encoded and appended to the URL
process()
This method will process the API response.
get( $url )
execute a "GET" request to the specified endpoint
post( $url )
execute a "POST" request to the specified endpoint
put( $url )
execute a "PUT" request to the specified endpoint
delete( $url )
execute a "DELETE" request to the specified endpoint
BASECLASS METHODS
request_agent
Accessor for the LWP::UserAgent request agent
request_object
Accessor for the HTTP::Request request object
request
Accessor for the HTTP::Request request object
request_content
Accessor for the complete request body from the HTTP::Request object
response_content
Accessor for the HTTP response body content
response_object
Accessor for the HTTP::Response response object
response
Accessor for the HTTP::Response response object
response_dom
Accessor for the LibXML response DOM
response_hash
Accessor for the hashified response content
response_json
Accessor for the json response content
nodeContent( $tag, [ $dom ] )
Helper for LibXML that retrieves node content
errors
Accessor to the hashref of errors
has_error
Returns true if the call contains errors
errors_as_string
Returns a string of API errors if there are any.
PRIVATE METHODS
_get_request_body
This method supplies the JSON body for the web service request
_get_request_headers
This methods supplies the headers for the RSS API call
_get_request_object
This method creates the request object and returns to the parent class
AUTHOR
Tim Keefer <tim@timkeefer.com>
COPYRIGHT
Tim Keefer 2009