- Timestamp:
- 05/31/08 03:05:29 (6 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/WebService-Simple/trunk/lib/WebService/Simple.pm
r12380 r12871 29 29 Carp::croak("base_url is required"); 30 30 my $basic_params = delete $args{params} || delete $args{param} || {}; 31 my $debug = delete $args{debug} || 0; 32 31 33 my $response_parser = delete $args{response_parser} || 32 34 $class->config->{response_parser}; … … 67 69 $self->{response_parser} = $response_parser; 68 70 $self->{cache} = $cache; 71 $self->{debug} = $debug; 69 72 return $self; 70 73 } … … 115 118 116 119 sub request_url { 117 my ($self, $url, %extra) = @_;118 my $uri = URI->new($self->base_url);119 120 if($url){121 $url =~ s!^/!!;122 $uri->path( $uri->path . $url);123 }124 125 map { utf8::encode($extra{$_}) if utf8::is_utf8($extra{$_}) } keys %extra;126 $uri->query_form( %{$self->basic_params}, %extra );127 128 return $uri;129 }130 131 sub get132 {133 120 my $self = shift; 134 121 my ($url, %extra); … … 144 131 } 145 132 146 my $uri = $self->request_url($url, %extra); 133 my $uri = URI->new($self->base_url); 134 if($url){ 135 $url =~ s!^/!!; 136 $uri->path( $uri->path . $url); 137 } 138 139 map { utf8::encode($extra{$_}) if utf8::is_utf8($extra{$_}) } keys %extra; 140 $uri->query_form( %{$self->basic_params}, %extra ); 141 142 return $uri; 143 } 144 145 sub get { 146 my $self = shift; 147 148 my $uri = $self->request_url(@_); 149 print "Request URL is $uri\n" if $self->{debug}; 147 150 148 151 my @headers = @_; … … 230 233 my $flickr = WebService::Simple->new( 231 234 base_url => "http://api.flickr.com/services/rest/", 232 param => { api_key => "your_api_key", } 235 param => { api_key => "your_api_key", }, 236 # debug => 1 233 237 ); 234 238 235 239 Create and return a new WebService::Simple object. 236 240 "new" Method requires a base_url of Web Service API. 241 If debug is set, dump a request URL in get or post method. 237 242 238 243 =item get(I<[$extra_path,] $args>) … … 254 259 Send POST request. 255 260 256 =item request_url(I< [%extra_path,]$args>)261 =item request_url(I<$extra_path, $args>) 257 262 258 263 Return reequest URL.
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)