| WWW-Stickam-API documentation | Contained in the WWW-Stickam-API distribution. |
WWW::Stickam::API - Perl implementation of Stickam API
my $api = WWW::Stickam::API->new();
if( $api->call('User/Profile' , { user_name => 'stickam' } ) ) {
print Dumper $api->get();
print $api->get_XML();
print $api->get_JSON();
}
else {
print $api->error ;
}
Perl implementation of Stickam API. See http://labs.stickam.jp/api/
This method call stickam API , take API name and parameters. Return true for success , false for fail.
get result in hash array format.
get result in XML
get result in JSON
get error message
get tv_interval. SEE Time::HiRes
WWW::Stickam::API::User::Audio
WWW::Stickam::API::User::Image
WWW::Stickam::API::User::Profile
WWW::Stickam::API::User::Video
WWW::Stickam::API::Media::Information
Tomohiro Teranishi <tomohiro.teranishi@gmail.com>
| WWW-Stickam-API documentation | Contained in the WWW-Stickam-API distribution. |
package WWW::Stickam::API; use strict; use warnings; use base qw/Class::Accessor::Fast/; use XML::Simple; use UNIVERSAL::require; use JSON::XS ; use Time::HiRes; our $VERSION = '0.02'; __PACKAGE__->mk_accessors(qw/data content error tv_interval/); sub call { my ( $s , $pkg , $args ) = @_; my $t0 = [ Time::HiRes::gettimeofday() ]; $pkg =~ s/\//::/g; $pkg = 'WWW::Stickam::API::' . $pkg ; $pkg->require or die "The API call[$pkg] is not available...[$@]"; my $api = $pkg->new(); if( $api->call( $args ) ) { $s->{content} = $api->content; $s->{tv_interval} = Time::HiRes::tv_interval( $t0 ); return 1; } else { $s->{error} = $api->error; $s->{tv_interval} = Time::HiRes::tv_interval( $t0 ); return ; } } sub get { my $s = shift; return XMLin( $s->{content} ); } sub get_XML { my $s = shift; return $s->{content}; } sub get_JSON { my $s = shift; my $data = $s->get(); return JSON::XS->new->utf8->pretty(1)->encode( $data );; } 1;