XML-RPC invocation tags are intended for advanced users who have a basic understanding of programming, whether in PHP or another language.
An example PHP script is included with OpenX for delivering XML-RPC data. However, a script could be written in any language to read and print the data returned by OpenX. XML-RPC is simply a ‘protocol which uses XML to encode its calls and HTTP as a transport mechanism’ (http://en.wikipedia.org/wiki/XML-RPC).
The XML-RPC tag generated by OpenX contains a comment above it with tips on placing the tag on your website, but this tutorial will go into advanced details.
A default tag (with the comment block removed) looks like this:
<?php
//ini_set('include_path', '.:/usr/local/lib');
require 'openads-xmlrpc.inc.php';
if (!isset($OA_context)) $OA_context = array();
$oaXmlRpc = new OA_XmlRpc('localhost', '/openads/www/delivery/axmlrpc.php', 0, false, 15);
$adArray = $oaXmlRpc->view('zone:6', 0, '', '', 0, $OA_context);
echo $adArray['html'];
?>
Note: Please generate the code from your OpenX installation, choosing the options you want from the invocation tag generation page. The above code will not work on your server because you will have different domain and path settings.
You must place the example file – openads-xmlrpc.inc.php – on the server of the publisher's website. You must then either change the 'ini_set' line to tell the script where this file is located, or you must change the 'require' line to use an absolute path:
// remove the 2 slashes to uncomment the ini_set line
ini_set('include_path', '.:/path/to/the/file');
// or, edit the require line:
require '/path/to/openads-xmlrpc.inc.php';
All lines except the 'echo' line at the end are intended to be placed before any output from your website. The 'echo' displays the banner on the website. In order to display multiple banners you will want to make multiple calls at the top of your document, and 'echo' the relevant banners where you wish.
To prevent displaying multiple banners we've added the option "Don't show the banner again on the same page" to the invocation tag, which uses the $OA_context array:
<?php
//ini_set('include_path', '.:/usr/local/lib');
require 'openads-xmlrpc.inc.php';
if (!isset($OA_context)) $OA_context = array();
$oaXmlRpc = new OA_XmlRpc('localhost', '/openads/www/delivery/axmlrpc.php', 0, false, 15);
// this is for 3 banners
// change $n<=3 to the # of banners you want
for ($n=1; $n++; $n<=3) {
$adArray[$n] = $oaXmlRpc->view('zone:6', 0, '', '', 0, $OA_context);
$OA_context[] = array('!=' => 'bannerid:'.$adArray['bannerid']);
}
?>




