The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WWW::OpenX::API - Access OpenX's XMLRPC API and manage your adserver from your perl scripts

VERSION

Version 0.01

SYNOPSIS

Allows you to manipulate OpenX by way of XMLRPC. Comes in handy if you want to build some custom tools for it.

use WWW::OpenX::API;

my $openx = WWW::OpenX::API->new(address => 'http://your.openx.server.here.com/www/api/v1/xmlrpc');

if($openx->login(username => 'username', password => 'password')) {
    print "We are logged in!";
}

SUBROUTINES/METHODS

login(%params)

Must be the first thing you call, parameters are 'username' and 'password'. This function will throw an exception if the username or password are incorrect, or when any other kind of error occurs.

call($function, @function_parameters)

Makes an XMLRPC call. See WWW::OpenX::API::Dispatch::Table for the full list of 'allowed' functions. Also see the OpenX API Documentation at http://developer.openx.org/api/.

Examples and notes:

Calling differences

boolean getAgencyZoneStatistics(string $sessionId, integer $agencyId, date $oStartDate, date $oEndDate, recordSet &$rsStatisticsData)

Is called as:

my $rsStatisticsData_ArrayRef = $openx-call('agencyZoneStatistics', $agencyId, $dateTime_startdate, $dateTime_enddate)>

Use of DateTime

When you see a reference to a 'date' value, feed it a DateTime object instead. The API module automatically converts it to the right format.

When you need a struct

When you see a reference to any OA_Dll_xxxxxInfo, you want to pass a hash reference as parameter. E.g.

$openx-call('updateAgency', { ... })>

ERROR HANDLING

Errors aren't really handled, it's your job to do that ;) The call function will throw exceptions whenever something goes wrong. You can inspect them based on their class name, and every exception has two functions:

code

Returns an error code, if applicable, but may be undef

message

Returns an error message.

Exceptions stringify to their message, in case you want to match on the message itself. All exception error messages are prefixed with the function call that caused the error to happen.

An example using Try::Tiny

my $value;
try {
    $value = $openx->call('getAgency', 10);
} catch {
    blessed($_) eq 'WWW::OpenX::API::Exception::RPC' and print "Something went wrong with an RPC call: ", $_->message
}

AUTHOR

Ben van Staveren, <benvanstaveren at gmail.com>

BUGS

Please report any bugs or feature requests to bug-www-openx-api at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-OpenX-API. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

There are, undoubtedly, a few bugs. This is my first attempt at Moose, and as such there will undoubtedly be better or cleaner ways to do it. Please feel free to submit patches :)

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc WWW::OpenX::API

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2010 Ben van Staveren.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 dated June, 1991 or at your option any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A copy of the GNU General Public License is available in the source tree; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.