[libflickr-api-perl] 05/40: imported 0.04
Lucas Kanashiro
kanashiro-guest at moszumanska.debian.org
Sat Jul 25 21:12:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
kanashiro-guest pushed a commit to tag 1.08
in repository libflickr-api-perl.
commit fa42766fd769d6f56353c07892191fce38467545
Author: Cal Henderson <cal at iamcal.com>
Date: Wed Apr 23 05:45:27 2008 +0000
imported 0.04
---
API.pm | 150 ------------------------------------------------------------
Changes | 6 ---
MANIFEST | 7 ++-
Makefile.PL | 3 +-
README | 3 +-
test.pl | 42 +++++++++++------
6 files changed, 35 insertions(+), 176 deletions(-)
diff --git a/API.pm b/API.pm
deleted file mode 100644
index 9646a7d..0000000
--- a/API.pm
+++ /dev/null
@@ -1,150 +0,0 @@
-package Flickr::API;
-
-use strict;
-use warnings;
-use LWP::UserAgent;
-use XML::Parser::Lite::Tree;
-use Flickr::API::Request;
-use Flickr::API::Response;
-
-our @ISA = qw(LWP::UserAgent);
-
-our $VERSION = '0.03';
-
-sub new {
- my $class = shift;
- my $options = shift;
- my $self = new LWP::UserAgent;
- $self->{api_key} = $options->{key};
- bless $self, $class;
- return $self;
-}
-
-sub execute_method {
- my ($self, $method, $args) = @_;
-
- my $request = new Flickr::API::Request({'method' => $method, 'args' => $args});
-
- $self->execute_request($request);
-}
-
-sub execute_request {
- my ($self, $request) = @_;
-
- $request->{api_args}->{method} = $request->{api_method};
- $request->{api_args}->{api_key} = $self->{api_key};
- $request->encode_args();
-
- my $response = $self->request($request);
- bless $response, 'Flickr::API::Response';
- $response->init_flickr();
-
- if ($response->{_rc} != 200){
- $response->set_fail(0, "API returned a non-200 status code ($response->{_rc})");
- return $response;
- }
-
- my $tree = XML::Parser::Lite::Tree::instance()->parse($response->{_content});
-
- my $rsp_node = $self->_find_tag($tree->{children});
-
- if ($rsp_node->{name} ne 'rsp'){
- $response->set_fail(0, "API returned an invalid response");
- return $response;
- }
-
- if ($rsp_node->{attributes}->{stat} eq 'fail'){
- my $fail_node = $self->_find_tag($rsp_node->{children});
- if ($fail_node->{name} eq 'err'){
- $response->set_fail($fail_node->{attributes}->{code}, $fail_node->{attributes}->{msg});
- }else{
- $response->set_fail(0, "Method failed but returned no error code");
- }
- return $response;
- }
-
- if ($rsp_node->{attributes}->{stat} eq 'ok'){
- $response->set_ok($rsp_node);
- return $response;
- }
-
- $response->set_fail(0, "API returned an invalid status code");
- return $response;
-}
-
-sub _find_tag {
- my ($self, $children) = @_;
- for my $child(@{$children}){
- return $child if $child->{type} eq 'tag';
- }
- return {};
-}
-
-1;
-__END__
-
-=head1 NAME
-
-Flickr::API - Perl interface to the Flickr API
-
-=head1 SYNOPSIS
-
- use Flickr::API;
-
- my $api = new Flickr::API({'key' => 'your_api_key'});
-
- my $response = $api->execute_method('flickr.test.echo', {
- 'foo' => 'bar',
- 'baz' => 'quux',
- });
-
-or
-
- use Flickr::API;
- use Flickr::API::Request;
-
- my $api = new Flickr::API({'key' => 'your_api_key'});
-
- my $request = new Flickr::API::Request({
- 'method' => 'flickr.test.echo',
- 'args' => {},
- });
-
- my $response = $api->execute_request($request);
-
-
-=head1 DESCRIPTION
-
-A simple interface for using the Flickr API.
-
-C<Flickr::API> is a subclass of L<LWP::UserAgent>, so all of the various
-proxy, request limits, caching, etc are available.
-
-=head2 METHODS
-
-=over 4
-
-=item C<execute_method($method, $args)>
-
-Constructs a C<Flickr::API::Request> object and executes it, returning a C<Flickr::API::Response> object.
-
-=item C<execute_request($request)>
-
-Executes a C<Flickr::API::Request> object, returning a C<Flickr::API::Response> object.
-
-=back
-
-
-=head1 AUTHOR
-
-Copyright (C) 2004, Cal Henderson, E<lt>cal at iamcal.comE<gt>
-
-=head1 SEE ALSO
-
-L<Flickr::API::Request>,
-L<Flickr::API::Response>,
-L<XML::Parser::Lite>,
-L<http://www.flickr.com/>,
-L<http://www.flickr.com/services/api/>
-
-=cut
diff --git a/Changes b/Changes
deleted file mode 100644
index a44e796..0000000
--- a/Changes
+++ /dev/null
@@ -1,6 +0,0 @@
-Revision history for Perl extension Flickr::API.
-
-0.01 Thu Aug 19 19:21:00 2004
- - original version; created by h2xs 1.21 with options
- -AXc -n Flickr::API
-
diff --git a/MANIFEST b/MANIFEST
index 533d093..73e1066 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,7 +1,6 @@
-API.pm
-API/Request.pm
-API/Response.pm
-Changes
+lib/Flickr/API.pm
+lib/Flickr/API/Request.pm
+lib/Flickr/API/Response.pm
Makefile.PL
MANIFEST
README
diff --git a/Makefile.PL b/Makefile.PL
index bb8f8a5..6f674e8 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -2,12 +2,13 @@ use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'Flickr::API',
- 'VERSION_FROM' => 'API.pm',
+ 'VERSION_FROM' => 'lib/Flickr/API.pm',
'PREREQ_PM' => {
'LWP::UserAgent' => 0,
'HTTP::Request' => 0,
'HTTP::Response' => 0,
'URI' => 0,
'XML::Parser::Lite::Tree' => 0.03,
+ 'Digest::MD5' => 0,
},
);
diff --git a/README b/README
index dfde2b9..76326a0 100644
--- a/README
+++ b/README
@@ -20,10 +20,11 @@ This module requires these other modules and libraries:
XML::Parser::Lite::Tree
LWP::UserAgent
+ Digest::MD5
COPYRIGHT AND LICENCE
-Copyright (C) 2004 Cal Henderson <cal at iamcal.com>
+Copyright (C) 2004-2005 Cal Henderson <cal at iamcal.com>
License: Perl Artistic License
diff --git a/test.pl b/test.pl
index 035b6da..43c126d 100644
--- a/test.pl
+++ b/test.pl
@@ -1,22 +1,36 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl test.pl'
+use Test;
+BEGIN { plan tests => 3 };
-#########################
+use Flickr::API;
+ok(1); #
-# change 'tests => 1' to 'tests => last_test_to_print';
+##################################################
+#
+# create an api object
+#
-use Test;
-BEGIN { plan tests => 2 };
-use Flickr::API;
-ok(1); # If we made it this far, we're ok.
+my $api = new Flickr::API({
+ 'key' => 'made_up_key',
+ 'secret' => 'my_secret',
+ });
+my $rsp = $api->execute_method('fake.method', {});
-#########################
-# Insert your test code below, the Test module is use()ed here so read
-# its man page ( perldoc Test ) for help writing this test script.
+##################################################
+#
+# check we get the 'method not found' error
+#
-my $api = new Flickr::API({'key' => 'made_up_key'});
-my $rsp = $api->execute_method('fake.method', {});
+ok($rsp->{error_code} == 0); # this error code will change in future!
+
+#print "code was $rsp->{error_code}, msg was $rsp->{error_message}\n";
+
+
+##################################################
+#
+# check the signing works properly
+#
-ok($rsp->{error_code} == 100); # error code for invalid key
+my $sig = $api->sign_args({'foo' => 'bar'});
+ok($sig eq '466cd24ced0b23df66809a4d2dad75f8');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libflickr-api-perl.git
More information about the Pkg-perl-cvs-commits
mailing list