- Timestamp:
- 09/28/07 10:23:33 (16 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/WebService-Coneco/trunk/lib/WebService/Coneco.pm
r270 r294 3 3 use warnings; 4 4 5 our $VERSION = '0.0 1';5 our $VERSION = '0.02'; 6 6 7 7 use Carp; 8 8 use URI; 9 9 use LWP::UserAgent; 10 10 11 use XML::Simple; 11 12 eval { require XML::Parser }; … … 23 24 24 25 my $coneco = WebService::Coneco->new( api_key => 'Your API Key'); 25 my $res = $coneco->call( 'ConecoMethodName', { arg1 => 'arg1', arg2 => 'arg2', } )26 or die $coneco->errstr;27 26 28 27 =head1 DESCRIPTION … … 51 50 } 52 51 53 =head2 call( $method, [\%method_options, \%parser_options])52 =head2 call( 'MethodName', \%options ) 54 53 55 54 =cut 56 55 57 56 sub call { 58 my ( $self, $method , $method_options, $parser_options ) = @_;59 croak $self->{errstr} = qq/Method required./ unless $method;57 my ( $self, $method_name, $method_options, $parser_options ) = @_; 58 croak qq/Method name is required./ unless $method_name; 60 59 61 my $query = { apikey => $self->{api_key}, }; 62 while ( my ( $key, $value ) = each %$method_options ) { 63 $query->{$key} = $value; 64 } 60 my $uri = URI->new( $APIBase . $method_name ); 61 $uri->query_form( 62 apikey => $self->{api_key}, 63 %$method_options, 64 ); 65 65 66 $self->{uri} = URI->new( $APIBase . $method ); 67 $self->{uri}->query_form($query); 68 69 my $res = $self->{ua}->request( HTTP::Request->new( GET => $self->{uri} ) ); 66 my $res = $self->{ua}->request( HTTP::Request->new( GET => $uri ) ); 70 67 71 68 $self->parse( $res, $parser_options ); … … 89 86 $data->{Header} = $parser->XMLin( $res->content )->{Header}; 90 87 if ( $data->{Header}->{Status} ne 'Success' ) { 91 $self->{errstr} = 92 qq/Response error: $data->{Header}->{Status}: $data->{Header}->{Detail}/; 88 $self->{errstr} = qq/Response error: $data->{Header}->{Status}: $data->{Header}->{Detail}/; 93 89 return; 94 90 } … … 103 99 sub errstr { 104 100 my $self = shift; 105 106 101 $self->{errstr}; 107 102 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)