Confluence::Client::XMLRPC - Client for the Atlassian Confluence wiki, based on RPC::XML
version 2.2
my $object = Confluence::Client::XMLRPC->new( <URL>, <user>, <pass> ); my $result = $object->method(argument,..);
ATTENTION, please: This module was written by Asgeir Nilsen in 2004 and later on improved by Giles Lewis, Martin Ellis, and Torben K. Jensen.
I - Heiko Jansen - only took the available source code and created a CPAN distribution for it, because at least to me a Perl module almost does not exist if it's not on available via CPAN.
This package should work with any remote API function.
The original authors tested it with addUserToGroup, getActiveUsers, getPage, getPages, getServerInfo, getUser, and storePage. I (Heiko Jansen) have used it successfully to create and update pages, but I did not test most other API functions and am thus unable to give any guarantee that it will work as expected!
addUserToGroup
getActiveUsers
getPage
getPages
getServerInfo
getUser
storePage
The original module was simply named "Confluence" but since Atlassian is currently working on a new REST-based API and since there already is Jira::Client and Jira::Client::REST on CPAN I renamed it to Confluence::Client::XMLRPC.
Confluence::Client::XMLRPC
This package has two global flags which control error handings.
Confluence::Client::XMLRPC::setRaiseError(1); # Enable die Confluence::Client::XMLRPC::setPrintError(1); # Enable warn Confluence::Client::XMLRPC::setRaiseError(0); # Disable die Confluence::Client::XMLRPC::setPrintError(0); # Disable warn
The setRaiseError and setPrintError functions both return the previous setting of the flag so that it may be restored if necessary.
setRaiseError
setPrintError
RaiseError is initially set to 1 to preserve the original package behavior.
PrintError is initially set to 0.
If RaiseError is set to 0 then Confluence::Client::XMLRPC::lastError() can be used to determine if an error occurred.
Confluence::Client::XMLRPC::lastError()
Confluence::Client::XMLRPC::setRaiseError(0); my $page = $wiki->getPage($space, $title); if ( my $e = Confluence::Client::XMLRPC::lastError() ) { say $e; }
Perl simple data types are mapped to string. Hash references are mapped to struct. Array references are mapped to array.
This package now automatically converts all scalars to RPC::XML::string, so explicit type conversions should not be required.
This package has a function called updatePage which is not part of the original remote API. If the page id is not specified then the function will call storePage to do an insert. If an "already exists" error is encountered then the function will call getPage to retrieve the page id and version, and then repeat the storePage attempt. This function is intended to be used in situations where the intent is to upload pages, overwriting existing content if it exists. See example below.
updatePage
upload_files.pl
The sample script uploads the contents of a directory to the wiki. Each file in the directory is uploaded as a separate page. The page title is the file name with extension removed. This script requires five arguments: API url, user name, password, space key and a directory name.
upload_users.pl
This script reads and loads a list of users from a file (or stdin). If errors are encountered then the script will print an error message, but continue processing. This script requires three arguments: API url, name and password of an admin user.
det_group_mbrship.pl
The script prints the group membership of all users. This script requires three arguments: API url, name and password of an admin user.
Please refer to the examples directory of the distribution for the scripts themselves.
examples
The package uses the RPC::XML module to do the heavy lifting. Read the perldoc for this package to learn more.
For further information on the Confluence API itself please refer to the official documentation as provided by Atlassian.
Asgeir Nilsen
Giles Lewis
Martin Ellis
Torben K. Jensen
Heiko Jansen <hjansen@cpan.org>
This software is Copyright (c) 2013 by Heiko Jansen.
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991
To install Confluence::Client::XMLRPC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Confluence::Client::XMLRPC
CPAN shell
perl -MCPAN -e shell install Confluence::Client::XMLRPC
For more information on module installation, please visit the detailed CPAN module installation guide.