Show
Ignore:
Timestamp:
04/18/08 16:58:49 (8 months ago)
Author:
daisuke
Message:

lang/perl/WebService-Simple; make the test accept a flickr API, and actually parse the response

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/WebService-Simple/branch/lwp-base/lib/WebService/Simple/Response.pm

    r8953 r9687  
     1# $Id$ 
     2 
    13package WebService::Simple::Response; 
     4use strict; 
     5use warnings; 
     6use base qw(HTTP::Response); 
    27 
    3 use warnings; 
    4 use strict; 
    5 use Carp; 
    6 use XML::Simple; 
    7 our $VERSION = '0.01'; 
     8sub new_from_response 
     9{ 
     10    # XXX hack. This probably should be changed... 
     11    my $class = shift; 
     12    my %args  = @_; 
     13    my $self = bless $args{response}, $class; 
     14    $self->{__parser} = $args{parser}; 
     15    return $self; 
     16} 
    817 
    9 sub HTTP::Response::parse_xml { 
    10     my ($self, $opt) = @_; 
    11     my $xs = XML::Simple->new( %$opt ); 
    12     my $results; 
    13     eval { $results = $xs->XMLin($self->content) }; 
    14     croak("can't parse xml") if ($@); 
    15     return $results; 
     18sub parse_response 
     19{ 
     20    my $self = shift; 
     21    return $self->{__parser}->parse_response($self); 
    1622} 
    1723