23 Jul, 2009 in Programming by Roger

.NET library for accessing the OpenX API

I’ve started work on a .NET library for manipulating an instance of OpenX 2.6+.

There’s quite a bit that this XML-RPC interface provides to developers. As such, I’ve only got the minimum of create, retrieve, update & delete methods implemented. There are more advanced methods for retrieving statistics which I’ haven’t begun work on yet. This library requires XMLRPC.NET.

So far, here is what my class has implemented:

  public OpenXApiV2(string endpointUrl, string username, string password)
  public string SessionId
  public void Logon()
  public bool Logoff()
  public int AddBanner(Banner newBanner)
  public Banner GetBanner(int bannerId)
  public bool ModifyBanner(Banner banner)
  public bool DeleteBanner(int bannerId)
  public Banner[] GetBannerListByCampaign(int campaignId)
  public int AddZone(Zone newZone)
  public Zone GetZone(int zoneId)
  public bool ModifyZone(Zone zone)
  public bool DeleteZone(int zoneId)
  public Zone[] GetZoneListByPublisher(int pubId)
  public void LinkBanner(int zoneId, int bannerId)
  public void UnlinkBanner(int zoneId, int bannerId)
  public void LinkCampaign(int zoneId, int campaignId)
  public void UnlinkCampaign(int zoneId, int campaignId)
  public int AddPublisher(Publisher newPub)
  public Publisher GetPublisher(int pubId)
  public bool ModifyPublisher(Publisher publisher)
  public bool DeletePublisher(int pubId)
  public Publisher[] GetPublishersByAgency(int agencyId)
  public int AddCampaign(Campaign newCampaign)
  public Campaign GetCampaign(int campaignId)
  public bool ModifyCampaign(Campaign campaign)
  public bool DeleteCampaign(int campaignId)
  public Campaign[] GetCampaignListByAdvertiser(int advertiserId)
  public int AddAgency(Agency newAgency)
  public Agency GetAgency(int agencyId)
  public bool ModifyAgency(Agency agency)
  public bool DeleteAgency(int agencyId)
  public Agency[] GetAgencyList()
  public int AddAdvertiser(Advertiser newAdvertiser)
  public Advertiser GetAdvertiser(int advertiserId)
  public bool ModifyAdvertiser(Advertiser advertiser)
  public bool DeleteAdvertiser(int advertiserId)
  public Advertiser[] GetAdvertiserListByAgency(int agencyId)
  public int AddChannel(Channel newChannel)
  public Channel GetChannel(int channelId)
  public bool ModifyChannel(Channel channel)
  public bool DeleteChannel(int channelId)
  public Channel[] GetChannelListByWebsite(int websiteId)
  public Channel[] GetChannelListByAgency(int agencyId)
  public int AddUser(User newUser)
  public User GetUser(int userId)
  public bool ModifyUser(User user)
  public bool DeleteUser(int userId)

I’ll continue implementing the remaining methods as I have time.

Download the OpenX.Net binary or OpenX.Net source code.

9/18/09, 1.1 – implemented LinkBanner, LinkCampaign, UnlinkBanner & UnlinkCampaign.

7/30/09 , 1.0 – initial release.

If you have any questions or suggestions, please leave a comment.

Share on Twitter

17 Responses so far | Have Your Say!

  1. Wavatar

    Indrani  |  April 5th, 2010 at 10:10 am #

    I am using your library to connect to OpenX API. But I am not being able to log into OpenX, as it throws an IllFormedXML Exception for some unknown reason.
    My code is:

    using DCC.OpenXClient;
    using DCC.OpenXClient.v2;
    using CookComputing.XmlRpc;

    protected void Page_Load(object sender, EventArgs e)
    {

    string Url = “”;
    string username = “”;
    string password = “”;

    OpenXApiV2 openxapi = new OpenXApiV2(“http://localhost/OpenX/www/api/v2/xmlrpc/LogonXmlRpcService.php”, “test@test.com”, “openx”);
    openxapi.Logon();
    }

    Please help. Do I need to do anything more than this?

    Thanks & Regards

  2. Wavatar

    Roger  |  April 5th, 2010 at 2:00 pm #

    @Indrani try just using: http://localhost/OpenX/www/api/v2/xmlrpc/ as the Endpoint URL.

    Also, your using this on OpenX 2.6+, correct?

  3. Wavatar

    Indrani  |  April 6th, 2010 at 11:04 am #

    Hi,

    Thanks. It worked.

    Regards,

  4. Wavatar

    Indrani  |  April 16th, 2010 at 9:44 am #

    hi,

    I have created zones and campaigns using DCC.OpenXClient.( DCC.OpenXClient.v2.Campaign c = new DCC.OpenXClient.v2.Campaign();
    )
    In campaign, I dont find any appropiate attribute to link campaign to zone.
    How do I link zones to campaigns/banners ?

    Regards,
    Indrani

  5. Wavatar

    Roger  |  April 16th, 2010 at 7:07 pm #

    @Indrani look at the LinkCampaign(int zoneId, int campaignId) method. That will bind the your banners/campaigns to a zone.

  6. Wavatar

    Indrani  |  April 16th, 2010 at 7:35 pm #

    hi,

    I cant find the LinkCampaign()method in campaign.
    DCC.OpenXClient.v2.Campaign c = new DCC.OpenXClient.v2.Campaign();
    c.??? could not find it.

    It will be very helpful if you kindly guide me.

    Thanks & Regards,
    Indrani

  7. Wavatar

    Roger  |  April 16th, 2010 at 8:35 pm #

    Sorry Indrani, I should have specified, the LinkCampaign method is on the OpenXApiV2 class.

  8. Wavatar

    Indrani  |  April 20th, 2010 at 1:12 pm #

    Hi,

    Thanks, I will try that.

    Currently,while adding a Publisher, the Web Url for the Publisher is not getting created.

    My Code:

    //PUBLISHER :
    Publisher newPub = new Publisher();
    newPub.publisherName = “My Example Website”;
    newPub.comments = “”;
    newPub.agencyId = 1;
    newPub.contactName = “John Doe”;
    newPub.emailAddress = “johnd@example.com”;
    newPub.website = “http://www.google.com”;
    newPub.publisherId = ox.AddPublisher(newPub);

    How do I add the Web URL ?

    Thanks & Regards,
    Indrani

  9. Wavatar

    Indrani  |  April 21st, 2010 at 5:18 am #

    Hi,

    After running the aforesaid code, when I go to OpenX, for the Publisher newly created the Web Url remains empty although other properties like name/contact/email are populated.
    How do I set the WebUrl as “newPub.website = “http://www.google.com”;” doesnt seem to work. :(

    Thanks & Regrards,

  10. Wavatar

    Roger  |  April 21st, 2010 at 1:33 pm #

    @Indrani, well after some digging it appears that this is a bug in the OpenX XML-RPC implementation. They aren’t pulling the value for website as they do the other fields that are populating correctly.

    Here’s a hack to try and get this to work if you really need it. It’s modifying the OpenX code so it will get wiped out if you do any updates plus I take no responsibility if it breaks something else :)

    Under your OpenX installation, open /lib/OA/Dll/Publisher.php

    At line 209 in my version, I’d insert a new line after as follows:
    $publisherData["website"] = $oPublisher->website;

    I haven’t tested it but it appears that’s what’s missing to get the website data stored correctly.

  11. Wavatar

    Indrani  |  April 22nd, 2010 at 6:40 am #

    Hi,

    Thanks it worked.

    Regards,

    Indrani

  12. Wavatar

    Indrani  |  April 26th, 2010 at 10:57 am #

    Hi,

    With regard to Banner, could you please help me to map attributes like Alt Text / Keywords / Text below / Status Text etc.

    Banner banner = new Banner();
    banner. // I DON’T FIND ANY APPROPRIATE PROPERTIES TO MAP THE AFORESAID ATTRIBUTES

    Thanks & Regards,

    Indrani

  13. Wavatar

    Roger  |  April 27th, 2010 at 7:25 pm #

    Ho Indrani, it looks like the properties you’re looking for aren’t exposed through the OpenX XML-RPC interface.

    It would take a quite a bit more hacking up of their implementation (which would break after an upgrade) and an enhancement to my library to implement what you’re looking for.

    Sorry, I know that’s not what you want to hear.

    Regards,
    Roger

  14. Wavatar

    Indrani  |  April 29th, 2010 at 7:37 am #

    Hi,

    I just have your dlls. If you don’t mind can I extend your library ? Would you please give me your source code.

    Thanks & Regards,
    Indrani

  15. Wavatar

    Roger  |  May 6th, 2010 at 3:16 pm #

    Hi Indrani, the source code is now available to download. The link is in the post above next to the binary download link.

    Enjoy!

  16. Wavatar

    Indrani  |  May 10th, 2010 at 11:14 am #

    hi,

    Cannot create a Banner.

    DCC.OpenXClient.v2.Banner onlineAds = new DCC.OpenXClient.v2.Banner();
    onlineAds.imageUrl =@”D:\Pics\fantasy\fantasy1.jpg” ;
    DCC.OpenXClient.v2.Image[] img= new DCC.OpenXClient.v2.Image[1];
    img[0].content=”sdsd”;
    img[0].filename=@”D:\Pics\fantasy\fantasy1.jpg”;
    onlineAds.aImage =img ;
    int bnr = ox.AddBanner(onlineAds);

  17. Wavatar

    Indrani  |  May 10th, 2010 at 11:15 am #

    always getting the error “Image file name empty”;

    Where am I going wrong ?

    Thanks & Regards,

    Indrani

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Twee60, created by Roger Dickey