For the last several months I was playing with OpenX, an open source ad server written in PHP. You can interact with OpenX in two ways: first by using the admin graphical interface, second by using API calls – most of the UI functionality can be programmatically reproduced.
OpenX is exposing its API through XML-RPC and they have a couple of examples on their website how to invoke the API from PHP, Java and Ruby. In my case I was trying to display some statistics without going through a middleware, so I started to investigate how can I do it from Flex. It turned out to be quite easy – one can use the AS3 RPC written by Akeem Philbert, with a small modification. The following steps should be done:
a) download the source code of the library from this location (http://code.google.com/p/as3-rpclib/)
b) you have to fix a small issue in the class com.ak33m.rpc.xmlrpc. XMLRPCObject (compatibility issue between SDK’s). The overloaded methods setCredentials and setRemoteCredentials should receive another parameter, called charset.
c)create the objects mapping the OpenX structures (advertiser, campaign, zone etc) and invoke the exposed methods
I did these steps and I created this Flash Builder project – you can import it into your workspace and change the file ServerConfig.as accordingly.
In my example I have just a couple of operations like login, displaying and creating advertisers. It can easily be extended in order to support the whole OpenX api.
Next post on OpenX will be about displaying the ads on your website, from Flash and HTML.