Atompub::Client(3pm) | User Contributed Perl Documentation | Atompub::Client(3pm) |
Atompub::Client - A client for the Atom Publishing Protocol
use Atompub::Client; my $client = Atompub::Client->new; $client->username('Melody'); $client->password('Nelson'); #$client->proxy( $proxy_uri ); # Get a Service Document my $service = $client->getService($service_uri); my @workspaces = $service->workspaces; my @collections = $workspaces[0]->collections; # CRUD an Entry Resource; assuming that the 0-th collection supports # Entry Resources my $collection_uri = $collections[0]->href; my $name = 'New Post'; my $entry = XML::Atom::Entry->new; $entry->title($name); $entry->content('Content of my post.'); my $edit_uri = $client->createEntry($collection_uri, $entry, $name); my $feed = $client->getFeed($collection_uri); my @entries = $feed->entries; $entry = $client->getEntry($edit_uri); $client->updateEntry($edit_uri, $entry); $client->deleteEntry($edit_uri); # CRUD a Media Resource; assuming that the 1-st collection supports # Media Resources my $collection_uri = $collections[1]->href; my $name = 'My Photo'; my $edit_uri = $client->createMedia($collection_uri, 'sample1.png', 'image/png', $name); # Get a href attribute of an "edit-media" link my $edit_media_uri = $client->resource->edit_media_link; my $binary = $client->getMedia($edit_media_uri); $client->updateMedia($edit_media_uri, 'sample2.png', 'image/png'); $client->deleteEntry($edit_media_uri); # Access to the requested HTTP::Request object my $request = $client->request; # Access to the received HTTP::Response object my $response = $client->response; # Access to the received resource (XML::Atom object or binary data) my $resource = $client->resource;
Atompub::Client implements a client for the Atom Publishing Protocol described at <http://www.ietf.org/rfc/rfc5023.txt>.
The client supports the following features:
Atompub::Client supports the Basic and WSSE Authentication described in <http://www.intertwingly.net/wiki/pie/DifferentlyAbledClients>.
Atompub::Client understands Service Documents, in which information of collections are described, such as URIs, acceptable media types, and allowable categories.
Media Resources (binary data) as well as Entry Resources are supported. You can create and edit Media Resources such as image and video by using Atompub::Client.
Atompub::Client checks media types of resources before creating and editing them to the collection. Acceptable media types are shown in app:accept elements in the Service Document.
Atompub::Client checks categories in Entry Resources before creating and editing them to the collection. Allowable categories are shown in app:categories elements in the Service Document.
On-memory cache and versioning, which are controlled by ETag and Last-Modified header, are implemented in Atompub::Client.
The client can specify Slug header when creating a resource, which may be used as part of the resource URI.
Creates a new Atompub client object. The options are same as LWP::UserAgent.
Retrieves a Service Document at URI $service_uri.
Returns an XML::Atom::Service object on success, false otherwise.
Retrieves a Category Document at URI $category_uri.
Returns an XML::Atom::Categories object on success, false otherwise.
Retrieves a Feed Document from the collection at URI $collection_uri.
Returns an XML::Atom::Feed object, false otherwise.
Creates a new entry in the collection at URI $collection_uri.
$entry must be an XML::Atom::Entry object.
If $slug is provided, it is set in Slug header and may be used as part of the resource URI.
Returns a Location header, which contains a URI of the newly created resource, or false on error.
Creates a new Media Resource and a Media Link Entry in the collection at URI $collection_uri.
If $media is a reference to a scalar, it is treated as the binary. If a scalar, treated as a file containing the Media Resource.
$media_type is the media type of the Media Resource, such as 'image/png'.
$slug is set in the Slug header, and may be used as part of the resource URI.
Returns a Location header, which contains a URI of the newly created resource, or false on error.
Retrieves an Entry Document with the given URI $edit_uri.
Returns an XML::Atom::Entry object on success, false otherwise. If the server returns 304 (Not Modified), returns a cache of the Media Resource.
Retrieves a Media Resource with the given URI $edit_uri.
Returns binary data of the Media Resource on success, false otherwise. If the server returns 304 (Not Modified), returns a cache of the Media Resource.
Updates the Entry Document at URI $edit_uri with the new Entry Document $entry, which must be an XML::Atom::Entry object.
Returns true on success, false otherwise.
Updates the Media Resource at URI $edit_uri with the $media.
If $media is a reference to a scalar, it is treated as the binary. If a scalar, treated as a file containing the Media Resource.
$media_type is the media type of the Media Resource, such as 'image/png'.
Returns true on success, false otherwise.
Deletes the Entry Document at URI $edit_uri.
Returns true on success, false otherwise.
Deletes the Media Resource at URI $edit_uri and related Media Link Entry.
Returns true on success, false otherwise.
If called with an argument, sets the username for login to $username.
Returns the current username that will be used when logging in to the Atompub server.
If called with an argument, sets the password for login to $password.
Returns the current password that will be used when logging in to the Atompub server.
If called with an argument, sets URI of proxy server like 'http://proxy.example.com:8080'.
Returns the current URI of the proxy server.
An accessor for Entry or Media Resource, which was retrieved in the previous action.
An accessor for an HTTP::Request object, which was used in the previous action.
An accessor for an HTTP::Response object, which was used in the previous action.
Accessor to the UserAgent.
An accessor to information of Collections described in a Service Document.
An accessor to the resource cache.
Methods return "undef" on error, and the error message can be retrieved using the errstr method.
XML::Atom XML::Atom::Service Atompub
Takeru INOUE, <takeru.inoue _ gmail.com>
Copyright (c) 2007, Takeru INOUE "<takeru.inoue _ gmail.com>". All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
2012-04-04 | perl v5.20.2 |