NAME
WebService::Simple - Simple interface to Web Services APIs
VERSION
This document describes WebService::Simple version 0.03
SYNOPSIS
use WebService::Simple;
my $flickr = WebService::Simple->new(
base_url => "http://api.flickr.com/services/rest/",
param => { api_key => "your_api_key", }
);
my $response =
$flickr->get( { method => "flickr.test.echo", name => "value" } );
my $ref = $response->parse_xml( { forcearray => [], keyattr => [] } );
print $ref->{name} . "\n";
DESCRIPTION
WebService::Simple provides you a simple interface to Web Services APIs
METHODS
- new(%args)
-
my $flickr = WebService::Simple->new( base_url => "http://api.flickr.com/services/rest/", param => { api_key => "your_api_key", } );
Create and return a new WebService::Simple object. "new" Method requires a base_url of Web Service API.
- get(%args)
-
my $response = $flickr->get( { method => "flickr.test.echo", name => "value" } );
Get the WebService::Simple::Response object.
If you want to add a path to base URL, use an option parameter.
my $lingr = WebService::Simple->new( base_url => "http://www.lingr.com/", param => { api_key => "your_api_key", format => "xml" } ); my $response = $lingr->get( {}, { path => "/api/session/create" } );
CACHING
Cache the response of Web Service APIs by using Cache object. Here's an example.
my $cache = Cache::File->new(
cache_root => "/tmp/mycache",
default_expires => "30 min",
);
my $flickr = WebService::Simple->new(
base_url => "http://api.flickr.com/services/rest/",
cache => $cache,
param => { api_key => $api_key, }
);
AUTHOR
Yusuke Wada <yusuke@kamawada.com>
COPYRIGHT AND LISENCE
Copyright (c) 2008 Yusuke Wada, 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.