Revive AdServer (Formerly OpenX Source) API – Introduction: Part 1

Share This

We use Revive AdServer (Formerly OpenX Source) frequently at BlackRiver as the most open and customizable ad serving platform both for many of our clients and our own internal projects. When it comes toRevive AdServer (Formerly OpenX Source)  API – there is almost nothing out there but a few blog posts and outdated code samples. We would really like to share our experiences (both positive and negative) withRevive AdServer (Formerly OpenX Source)  API as we strongly believe that theRevive AdServer (Formerly OpenX Source)  platform should remain easy accessible and open to the public.

As you might already know, theRevive AdServer (Formerly OpenX Source) API service allows us to gain remote control of pretty much the entire functionality of the ad serving platform.Revive AdServer (Formerly OpenX Source) provides us with two versions (v1 and v2) of the API. You can still find some minimal documentation on v1 version of the API, but it has been deprecated since OpenX Source 2.7, thus we are going to focus on v2. The API service is based on the RPC (criticized by many as being inferior to REST) protocol, so as an obvious solution, we decided to use the latest PHP XML_RPC2 library provided by PEAR (http://pear.php.net/package/XML_RPC2/). The installation is fairly straight forward, if you have PEAR already installed, simply run pear install XML_RPC2

Now with the XML_RPC2 library setup, let us look into a specific code example:

require_once 'XML/RPC2/Client.php';
$oxLogin = array("username"=>"admin","password"=>"admin_password");
$opts = array('prefix' => 'ox.');
$advertiserId = 3;
 
$client = XML_RPC2_Client::create('http://domain.com/openx/www/api/v2/xmlrpc/', $opts);
 
try {
 
    $sessionId = $client->logon($oxLogin['username'],$oxLogin['password']);
 
    $result = $client->getAdvertiser($sessionId,$advertiserId);
    print_r($result);
 
    $result = $client->advertiserDailyStatistics($sessionId,$advertiserId);
    print_r($result);
 
    $client->logoff($sessionId);
 
} catch (XML_RPC2_FaultException $e) {
 
    // The XMLRPC server returns a XMLRPC error
    die('Exception #' . $e->getFaultCode() . ' : ' . $e->getFaultString());
 
} catch (Exception $e) {
 
    // Other errors (HTTP or networking problems...)
    die('Exception : ' . $e->getMessage());
 
}

Even though the above code is fairly self-explanatory, there are a few things to take into consideration. The login credentials MUST be of the main account used on theRevive AdServer (Formerly OpenX Source)  installation, creating a separate administrator account just for the API service is not going to work. The “ox.” prefix for the RPC service is default and does not need to be changed. In this example, we authenticate (login) with the API, and then use the sessionId to retrieve a specific advertiser’s information as well as the daily stats for that specific advertiser. The advertiserDailyStatistics function returns an array of all days in which the advertiser was active, if there is no specific date passed as one of the parameters.

In the next little while, we are going to post more articles on specificRevive AdServer (Formerly OpenX Source)  API functions (perhaps even a full list with explanations – which was never provided by the formerly OpenX Source core team) and how to control Revive AdServer (Formerly OpenX Source) Advertisers, Publishers, Campaigns, Zones and Banners as well as customRevive AdServer (Formerly OpenX Source)  delivery limitations plugins and integration with open-source platforms like WordPress.


4 Responses to “Revive AdServer (Formerly OpenX Source) API – Introduction: Part 1”

  1. Erik Geurts says:

    Hi,

    Thanks for this post and for sharing all of this valuable information.

    A developer named Rade Popovic made a REST ‘wrapper’ that sites on top of the OpenX API to make all of the API functionality available through a REST interface. You can find it a http://www.openxsourcerestapi.com

    Best regards, Erik Geurts – OpenX consultant

  2. Priyanka says:

    Issue – While creating campaign using “AddCampaign” method of “CampaignService”, we are setting the region to a specific country as Sweden (#198) through RegionStruct as a part of TargetingStruct. When we get the campaign data for the same campaign using “GetCampaign” method, we get the country id as 198. However, when logged in to http://www.ac.openx.com, we could not see country set to Sweden and it shows default option as “Target All Locations”.

    What other ways we tried?
    1) We tried setting specific country, but we faced the same challenge.
    2) We raised this on OpenX market forum, but did not get any reply yet. Please see attached.
    3) We tried sending separate additional tag for regional targeting while calling “AddCampaign” method, but did not work.

    API Reference Used:
    1) PDF documents shared by you on yammer (OpenX Market_API_1.pdf, OpenX Market_API_2.pdf).
    2) http://openx.com/sites/default/files/images/openxmkt_api_ac.pdf This document is last updated on 21st Nov 2011.

  3. […] The package comes with a sample PHP client and examples of all possible REST calls included in the API. It makes the initial implementation a breeze – you never have to guess which parameters and what format you have to use in the API calls (unlike the default XML-RPC wrapper). […]

  4. sanjay says:

    i want to use the openx api version 4.0 via c#.net.

    I have consumer key and consumer secret key, now my only question is that what is the auth url we need to form for authenticating the user and then access api after that, like webspectator have it : http://wsp.webspectator.com/PublicServices/GetAutoMonetizerReportByDate?key=%5Baccountkey%5D&
    dateStart=[yyyy-mm-dd]&dateEnd=[yyyy-mm-dd]&websites=[websites-public-key]

    this sort of url i need to form for authentication of the user, since i am using c#.net there is no client library are available for .net, so i need to create my own library.

Leave a Reply

Recent Revive AdServer (Formerly OpenX Source) Expandable Banners

Revive AdServer (Formerly OpenX Source)  Expandable Banners The following example demonstrates a 600px by 150px banner served by Revive AdServer (Formerly OpenX Source)  and expanded to 600px by 300px on rollover. The flash creative can be either uploaded to creatives directory directly (FTP) or just as an another Revive AdServer (Formerly OpenX Source)  banner (preferred). When uploading the SWF creative, you do not need to replace any hardcoded URLs or indicate a destination URL – that would be done in the HTML banner setup. Essentially, we are just using it as a storage container for our creative, all impressions and clicks will be … read more

 Twitter  LinkedIn  Google+  Skype RSS

Get in Touch

  • r Phone:
    (416) 877 2844 / (647) 258 4847
  • h Email:
    company@blackriver.to
  • m Address:
    1454 Dundas St. East, Suite 124
    Mississauga, Ontario
    L4X1L4, Canada

Any Questions?

Email

Message