.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Atompub::Client 3pm" .TH Atompub::Client 3pm 2024-03-04 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Atompub::Client \- A client for the Atom Publishing Protocol .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Atompub::Client; \& \& my $client = Atompub::Client\->new; \& $client\->username(\*(AqMelody\*(Aq); \& $client\->password(\*(AqNelson\*(Aq); \& #$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 = \*(AqNew Post\*(Aq; \& \& my $entry = XML::Atom::Entry\->new; \& $entry\->title($name); \& $entry\->content(\*(AqContent of my post.\*(Aq); \& \& 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 = \*(AqMy Photo\*(Aq; \& \& my $edit_uri = $client\->createMedia($collection_uri, \*(Aqsample1.png\*(Aq, \& \*(Aqimage/png\*(Aq, $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, \*(Aqsample2.png\*(Aq, \*(Aqimage/png\*(Aq); \& \& $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; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Atompub::Client implements a client for the Atom Publishing Protocol described at . .PP The client supports the following features: .IP \(bu 4 Authentication .Sp Atompub::Client supports the Basic and WSSE Authentication described in . .IP \(bu 4 Service Document .Sp Atompub::Client understands Service Documents, in which information of collections are described, such as URIs, acceptable media types, and allowable categories. .IP \(bu 4 Media Resource support .Sp 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. .IP \(bu 4 Media type check .Sp Atompub::Client checks media types of resources before creating and editing them to the collection. Acceptable media types are shown in \fIapp:accept\fR elements in the Service Document. .IP \(bu 4 Category check .Sp Atompub::Client checks categories in Entry Resources before creating and editing them to the collection. Allowable categories are shown in \fIapp:categories\fR elements in the Service Document. .IP \(bu 4 Cache controll and versioning .Sp On-memory cache and versioning, which are controlled by \fIETag\fR and \fILast-Modified\fR header, are implemented in Atompub::Client. .IP \(bu 4 Naming resources by \fISlug\fR header .Sp The client can specify \fISlug\fR header when creating a resource, which may be used as part of the resource URI. .SH METHODS .IX Header "METHODS" .ie n .SS "Atompub::Client\->new([ %options ])" .el .SS "Atompub::Client\->new([ \f(CW%options\fP ])" .IX Subsection "Atompub::Client->new([ %options ])" Creates a new Atompub client object. The options are same as LWP::UserAgent. .ie n .SS $client\->getService($service_uri) .el .SS \f(CW$client\fP\->getService($service_uri) .IX Subsection "$client->getService($service_uri)" Retrieves a Service Document at URI \f(CW$service_uri\fR. .PP Returns an XML::Atom::Service object on success, false otherwise. .ie n .SS $client\->getCategories($category_uri) .el .SS \f(CW$client\fP\->getCategories($category_uri) .IX Subsection "$client->getCategories($category_uri)" Retrieves a Category Document at URI \f(CW$category_uri\fR. .PP Returns an XML::Atom::Categories object on success, false otherwise. .ie n .SS $client\->getFeed($collection_uri) .el .SS \f(CW$client\fP\->getFeed($collection_uri) .IX Subsection "$client->getFeed($collection_uri)" Retrieves a Feed Document from the collection at URI \f(CW$collection_uri\fR. .PP Returns an XML::Atom::Feed object, false otherwise. .ie n .SS "$client\->createEntry($collection_uri, $entry, [ $slug ])" .el .SS "\f(CW$client\fP\->createEntry($collection_uri, \f(CW$entry\fP, [ \f(CW$slug\fP ])" .IX Subsection "$client->createEntry($collection_uri, $entry, [ $slug ])" Creates a new entry in the collection at URI \f(CW$collection_uri\fR. .PP \&\f(CW$entry\fR must be an XML::Atom::Entry object. .PP If \f(CW$slug\fR is provided, it is set in \fISlug\fR header and may be used as part of the resource URI. .PP Returns a \fILocation\fR header, which contains a URI of the newly created resource, or false on error. .ie n .SS "$client\->createMedia($collection_uri, $media, $media_type, [ $slug ])" .el .SS "\f(CW$client\fP\->createMedia($collection_uri, \f(CW$media\fP, \f(CW$media_type\fP, [ \f(CW$slug\fP ])" .IX Subsection "$client->createMedia($collection_uri, $media, $media_type, [ $slug ])" Creates a new Media Resource and a Media Link Entry in the collection at URI \f(CW$collection_uri\fR. .PP If \f(CW$media\fR is a reference to a scalar, it is treated as the binary. If a scalar, treated as a file containing the Media Resource. .PP \&\f(CW$media_type\fR is the media type of the Media Resource, such as 'image/png'. .PP \&\f(CW$slug\fR is set in the \fISlug\fR header, and may be used as part of the resource URI. .PP Returns a \fILocation\fR header, which contains a URI of the newly created resource, or false on error. .ie n .SS $client\->getEntry($edit_uri) .el .SS \f(CW$client\fP\->getEntry($edit_uri) .IX Subsection "$client->getEntry($edit_uri)" Retrieves an Entry Document with the given URI \f(CW$edit_uri\fR. .PP Returns an XML::Atom::Entry object on success, false otherwise. If the server returns 304 (Not Modified), returns a cache of the Media Resource. .ie n .SS $client\->getMedia($edit_uri) .el .SS \f(CW$client\fP\->getMedia($edit_uri) .IX Subsection "$client->getMedia($edit_uri)" Retrieves a Media Resource with the given URI \f(CW$edit_uri\fR. .PP 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. .ie n .SS "$client\->updateEntry($edit_uri, $entry)" .el .SS "\f(CW$client\fP\->updateEntry($edit_uri, \f(CW$entry\fP)" .IX Subsection "$client->updateEntry($edit_uri, $entry)" Updates the Entry Document at URI \f(CW$edit_uri\fR with the new Entry Document \f(CW$entry\fR, which must be an XML::Atom::Entry object. .PP Returns true on success, false otherwise. .ie n .SS "$client\->updateMedia($edit_uri, $media, $media_type)" .el .SS "\f(CW$client\fP\->updateMedia($edit_uri, \f(CW$media\fP, \f(CW$media_type\fP)" .IX Subsection "$client->updateMedia($edit_uri, $media, $media_type)" Updates the Media Resource at URI \f(CW$edit_uri\fR with the \f(CW$media\fR. .PP If \f(CW$media\fR is a reference to a scalar, it is treated as the binary. If a scalar, treated as a file containing the Media Resource. .PP \&\f(CW$media_type\fR is the media type of the Media Resource, such as 'image/png'. .PP Returns true on success, false otherwise. .ie n .SS $client\->deleteEntry($edit_uri) .el .SS \f(CW$client\fP\->deleteEntry($edit_uri) .IX Subsection "$client->deleteEntry($edit_uri)" Deletes the Entry Document at URI \f(CW$edit_uri\fR. .PP Returns true on success, false otherwise. .ie n .SS $client\->deleteMedia($edit_uri) .el .SS \f(CW$client\fP\->deleteMedia($edit_uri) .IX Subsection "$client->deleteMedia($edit_uri)" Deletes the Media Resource at URI \f(CW$edit_uri\fR and related Media Link Entry. .PP Returns true on success, false otherwise. .SH Accessors .IX Header "Accessors" .ie n .SS "$client\->username([ $username ])" .el .SS "\f(CW$client\fP\->username([ \f(CW$username\fP ])" .IX Subsection "$client->username([ $username ])" If called with an argument, sets the username for login to \f(CW$username\fR. .PP Returns the current username that will be used when logging in to the Atompub server. .ie n .SS "$client\->password([ $password ])" .el .SS "\f(CW$client\fP\->password([ \f(CW$password\fP ])" .IX Subsection "$client->password([ $password ])" If called with an argument, sets the password for login to \f(CW$password\fR. .PP Returns the current password that will be used when logging in to the Atompub server. .ie n .SS "$client\->proxy([ $proxy_uri ])" .el .SS "\f(CW$client\fP\->proxy([ \f(CW$proxy_uri\fP ])" .IX Subsection "$client->proxy([ $proxy_uri ])" If called with an argument, sets URI of proxy server like 'http://proxy.example.com:8080'. .PP Returns the current URI of the proxy server. .ie n .SS $client\->resource .el .SS \f(CW$client\fP\->resource .IX Subsection "$client->resource" .ie n .SS $client\->rc .el .SS \f(CW$client\fP\->rc .IX Subsection "$client->rc" An accessor for Entry or Media Resource, which was retrieved in the previous action. .ie n .SS $client\->request .el .SS \f(CW$client\fP\->request .IX Subsection "$client->request" .ie n .SS $client\->req .el .SS \f(CW$client\fP\->req .IX Subsection "$client->req" An accessor for an HTTP::Request object, which was used in the previous action. .ie n .SS $client\->response .el .SS \f(CW$client\fP\->response .IX Subsection "$client->response" .ie n .SS $client\->res .el .SS \f(CW$client\fP\->res .IX Subsection "$client->res" An accessor for an HTTP::Response object, which was used in the previous action. .SH "INTERNAL INTERFACES" .IX Header "INTERNAL INTERFACES" .ie n .SS $client\->init .el .SS \f(CW$client\fP\->init .IX Subsection "$client->init" .ie n .SS $client\->ua .el .SS \f(CW$client\fP\->ua .IX Subsection "$client->ua" Accessor to the UserAgent. .ie n .SS $client\->info .el .SS \f(CW$client\fP\->info .IX Subsection "$client->info" An accessor to information of Collections described in a Service Document. .ie n .SS $client\->cache .el .SS \f(CW$client\fP\->cache .IX Subsection "$client->cache" An accessor to the resource cache. .ie n .SS $client\->munge_request($req) .el .SS \f(CW$client\fP\->munge_request($req) .IX Subsection "$client->munge_request($req)" .ie n .SS $client\->_clear .el .SS \f(CW$client\fP\->_clear .IX Subsection "$client->_clear" .ie n .SS $client\->_get_service(\e%args) .el .SS \f(CW$client\fP\->_get_service(\e%args) .IX Subsection "$client->_get_service(%args)" .ie n .SS $client\->_get_categories(\e%args) .el .SS \f(CW$client\fP\->_get_categories(\e%args) .IX Subsection "$client->_get_categories(%args)" .ie n .SS $client\->_get_feed(\e%args) .el .SS \f(CW$client\fP\->_get_feed(\e%args) .IX Subsection "$client->_get_feed(%args)" .ie n .SS $client\->_create_resource(\e%args) .el .SS \f(CW$client\fP\->_create_resource(\e%args) .IX Subsection "$client->_create_resource(%args)" .ie n .SS $client\->_get_resource(\e%args) .el .SS \f(CW$client\fP\->_get_resource(\e%args) .IX Subsection "$client->_get_resource(%args)" .ie n .SS $client\->_update_resource(\e%args) .el .SS \f(CW$client\fP\->_update_resource(\e%args) .IX Subsection "$client->_update_resource(%args)" .ie n .SS $client\->_delete_resource(\e%args) .el .SS \f(CW$client\fP\->_delete_resource(\e%args) .IX Subsection "$client->_delete_resource(%args)" .SH "ERROR HANDLING" .IX Header "ERROR HANDLING" Methods return \f(CW\*(C`undef\*(C'\fR on error, and the error message can be retrieved using the \fIerrstr\fR method. .SH "SEE ALSO" .IX Header "SEE ALSO" XML::Atom XML::Atom::Service Atompub .SH AUTHOR .IX Header "AUTHOR" Takeru INOUE, .SH "LICENCE AND COPYRIGHT" .IX Header "LICENCE AND COPYRIGHT" Copyright (c) 2007, Takeru INOUE \f(CW\*(C`\*(C'\fR. All rights reserved. .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. .SH "DISCLAIMER OF WARRANTY" .IX Header "DISCLAIMER OF WARRANTY" 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. .PP 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.