b0VIM 6.2      x	AvP t*  btrott                                  bambou.local                            ~btrott/devel/xml-atom/lib/XML/Atom/Client.pm                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       0123 !"#U                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     pt                      |            Y                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             da       2                    g  S  =  (            w  2  1  '                y  e  '                s  q  p  a  I  "  	                    r  H  ,  *  )      
  
  
  
P  
.  	  	  	  	  	  	  	q  	\  	,            \                  Z  (  
          E  #                  7                  u  F        v  ;  0  .  -            ~  t  r  q  ]  E  2      my($req) = @_;     my $client = shift; sub munge_request {  }     $res;     $client->munge_response($res);     my $res = $client->{ua}->request($req);     $client->munge_request($req);     my($req) = @_;     my $client = shift; sub make_request {  }     $feed;         or return $client->error(XML::Atom::Feed->errstr);     my $feed = XML::Atom::Feed->new(Stream => \$res->content)         unless $res->code == 200;     return $client->error("Error on GET $uri: " . $res->status_line)     my $res = $client->make_request($req);     my $req = HTTP::Request->new(GET => $uri);         unless $uri;     return $client->error("Must pass a FeedURI before retrieving feed")     my($uri) = @_;     my $client = shift; sub getFeed {  }     1;         unless $res->code == 200;     return $client->error("Error on DELETE $url: " . $res->status_line)     my $res = $client->make_request($req);     my $req = HTTP::Request->new(DELETE => $url);     my($url) = @_;     my $client = shift; sub deleteEntry {  }     1;         unless $res->code == 200;     return $client->error("Error on PUT $url: " . $res->status_line)     my $res = $client->make_request($req);     $req->content($xml);     $req->content_length(length $xml);     _utf8_off($xml);     my $xml = $entry->as_xml;     $req->content_type('application/x.atom+xml');     my $req = HTTP::Request->new(PUT => $url);     my($url, $entry) = @_;     my $client = shift; sub updateEntry {  }     $res->header('Location') || 1;         unless $res->code == 201;     return $client->error("Error on POST $uri: " . $res->status_line)     my $res = $client->make_request($req);     $req->content($xml);     $req->content_length(length $xml);     _utf8_off($xml);     my $xml = $entry->as_xml;     $req->content_type('application/x.atom+xml');     my $req = HTTP::Request->new(POST => $uri);         unless $uri;     return $client->error("Must pass a PostURI before posting")     my($uri, $entry) = @_;     my $client = shift; sub createEntry {  }     XML::Atom::Entry->new(Stream => \$res->content);         unless $res->code == 200;     return $client->error("Error on GET $url: " . $res->status_line)     my $res = $client->make_request($req);     my $req = HTTP::Request->new(GET => $url);     my($url) = @_;     my $client = shift; sub getEntry {  }     $client->{auth_digest};     $client->{auth_digest} = shift if @_;     my $client = shift; sub auth_digest {  }     $client->{use_soap};     $client->{use_soap} = shift if @_;     my $client = shift; sub use_soap {  }     $client->{password};     $client->{password} = shift if @_;     my $client = shift; sub password {  }     $client->{username};     $client->{username} = shift if @_;     my $client = shift; sub username {  }     $client;     $client->{ua}->agent('XML::Atom/' . XML::Atom->VERSION);     $client->{ua} = LWP::UserAgent::AtomClient->new($client);     my %param = @_;     my $client = shift; sub init {  }     $client;     $client->init(@_) or return $class->error($client->errstr);     my $client = bless { }, $class;     my $class = shift; sub new {  use constant NS_SOAP => 'http://schemas.xmlsoap.org/soap/envelope/'; use constant NS_ATOM => 'http://purl.org/atom/ns#';  use DateTime; use MIME::Base64 qw( encode_base64 ); use Digest::SHA1 qw( sha1 ); use XML::Atom::Util qw( first textValue ); use XML::Atom::Feed; use XML::Atom::Entry; use LWP::UserAgent; use base qw( XML::Atom::ErrorHandler ); use XML::Atom;  use strict; package XML::Atom::Client;  # $Id: Client.pm,v 1.22 2004/07/29 16:48:18 btrott Exp $ da    U        Y        t  R  Q  '  &          `                    v  u  (      F  @  ?  (  '          s  r  ,      
  
  
  
  
h  
[  
Z  
/  
.  
  
  	  	  	  	  	  	  	i  	h  	=  	<                Z  Y  :  9                _  C  B  (  '                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           =cut  information. Please see the I<XML::Atom> manpage for author, copyright, and license  =head1 AUTHOR & COPYRIGHT  using the I<errstr> method. Methods return C<undef> on error, and the error message can be retrieved  =head2 ERROR HANDLING  from the server. Returns an I<XML::Atom::Feed> object representing the feed returned  Retrieves the feed at I<$FeedURI>.  =head2 $api->getFeed($FeedURI)  Deletes the entry at URL I<$EditURI>.  =head2 $api->deleteEntry($EditURI)  Returns true on success, false otherwise.  an I<XML::Atom::Entry> object. Updates the entry at URL I<$EditURI> with the entry I<$entry>, which must be  =head2 $api->updateEntry($EditURI, $entry)  Returns an I<XML::Atom::Entry> object.  Retrieves the entry with the given URL I<$EditURI>.  =head2 $api->getEntry($EditURI)  I<$entry> must be an I<XML::Atom::Entry> object.  Creates a new entry.  =head2 $api->createEntry($PostURI, $entry)  Atom server. Returns the current password that will be used when logging in to the  If called with an argument, sets the password for login to I<$password>.  =head2 $api->password([ $password ])  Atom server. Returns the current username that will be used when logging in to the  If called with an argument, sets the username for login to I<$username>.  =head2 $api->username([ $username ])  If called without arguments, returns the current value of the flag.      $api->use_soap(1);  C<1>: that supports only the SOAP wrapper--by calling I<use_soap> with a value of turn on the SOAP wrapper--for example, if you need to connect to a server Atom API. By default, the REST version of the API will be used, but you can I<XML::Atom::Client> supports both the REST and SOAP-wrapper versions of the  =head2 $api->use_soap([ 0 | 1 ])  =head2 XML::Atom::Client->new(%param)  =head1 USAGE  in flux. B<NOTE:> the API, and particularly the authentication scheme, are still  I<http://www.intertwingly.net/wiki/pie/DifferentlyAbledClients>. authentication scheme described at I<http://bitworking.org/projects/atom/draft-gregorio-09.html>, with the I<XML::Atom::Client> implements a client for the Atom API described at  =head1 DESCRIPTION      my $entry = $api->getEntry($EditURI);      my @entries = $feed->entries;     my $feed = $api->getFeed($FeedURI);      my $EditURI = $api->createEntry($PostURI, $entry);     $entry->content('Content of my post.'); da             |        v  G          ]  :          U  E  1        Z  2                  r  m  P  %  
  
  
  
{  
T  	  	  	t  	n  	l  	k  	V  	>  	+          o  ^  +          A          j  '                    o  X  @                          n  P  G  E  D  (               n  Q  O  N  K  C  B  6  5                |  ^  ]  6                       $entry->title('New Post');     my $entry = XML::Atom::Entry->new;      $api->password('Nelson');     $api->username('Melody');     my $api = XML::Atom::Client->new;     use XML::Atom::Entry;     use XML::Atom::Client;  =head1 SYNOPSIS  XML::Atom::Client - A client for the Atom API  =head1 NAME  __END__ 1;  }     delete $ClientOf{$self};     my $self = shift; sub DESTROY {  }     return $client->username, $client->password;     my $client = $ClientOf{$ua} or die "Cannot find $ua";     my($ua, $realm, $url, $proxy) = @_; sub get_basic_credentials {  }     $ua;     $ClientOf{$ua} = $client;     my $ua = $class->SUPER::new;     my($class, $client) = @_; sub new { my %ClientOf;  use base qw( LWP::UserAgent );  use strict; package LWP::UserAgent::AtomClient;  }     }         Encode::_utf8_off($val);         require Encode;     if ($] >= 5.008) {     my $val = shift; sub _utf8_off {  sub make_nonce { sha1(sha1(time() . {} . rand() . $$)) }  }     }         }             $res->content_length(1);             $res->content($xml);                 LIBXML ? $body->childNodes : $body->getChildNodes;             $xml = join '', map $_->toString(LIBXML ? 1 : 0),         } else {             $res->content_length(0);             $res->content('');             $res->message(textValue($fault, undef, 'faultstring'));             $res->code(textValue($fault, undef, 'faultcode'));         if (my $fault = first($body, NS_SOAP, 'Fault')) {         my $body = first($doc, NS_SOAP, 'Body');         }             $doc = ($xp->find('/')->get_nodelist)[0];             my $xp = XML::XPath->new(xml => $xml);         } else {             $doc = $parser->parse_string($xml);             my $parser = XML::LibXML->new;         if (LIBXML) {         my $doc;     if ($client->use_soap && (my $xml = $res->content)) {     my($res) = @_;     my $client = shift; sub munge_response {  }     }         $req->header('Authorization', 'WSSE profile="UsernameToken"');           $client->username || '', $digest, $nonce_enc, $now);           qq(UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"),         $req->header('X-WSSE', sprintf     } else {         $req->content_type('text/xml');         $req->method('POST');         $req->header('SOAPAction', 'http://schemas.xmlsoap.org/wsdl/http/' . $method);         $req->content_length(length $xml);         $req->content($xml); SOAP </soap:Envelope>   </soap:Body>     </$method> $xml     <$method xmlns="http://schemas.xmlsoap.org/wsdl/http/">   <soap:Body>   </soap:Header>     </wsse:Security>       </wsse:UsernameToken>         <wsu:Created>$now</wsu:Created>         <wsse:Nonce>$nonce_enc</wsse:Nonce>         <wsse:Password Type="wsse:PasswordDigest">$digest</wsse:Password>         <wsse:Username>@{[ $client->username || '' ]}</wsse:Username>       <wsse:UsernameToken>     <wsse:Security>   <soap:Header>   xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">   xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" <soap:Envelope         $xml = ($1 || '') . <<SOAP;         my $method = $req->method;         $xml =~ s!^(<\?xml.*?\?>)!!;         my $xml = $req->content || '';     if ($client->use_soap) {     my $digest = encode_base64(sha1($nonce . $now . ($client->password || '')), '');     my $now = DateTime->now->iso8601 . 'Z';     my $nonce_enc = encode_base64($nonce, '');     my $nonce = $client->make_nonce;     );         Accept => 'application/x.atom+xml, application/xml, text/xml, */*',     $req->header( 