Jun 26 2008
Jeremy Schoemaker

AzoogleAds Soap API With PHP4

By Jeremy Schoemaker 47 comments

I have been wanting to use the AzoogleAds SOAP API (Advanced Programing Interface) for some time now. Its one of those things that was "on the list" to get to eventually. Last week I got a wild hair and played around with it. I downloaded their PDF but kept getting all kinds of errors when trying to follow it. I pinged some of their developers and they told me to disregard the documentation and helped me get it working.

When I was searching the web I also noticed a lot of other people having the same problems I was so I thought I would post some very basic instructions to get it working.

The first thing you need to do is download the Nusoap library to proccess the SOAP stuff.

Unpack it somewhere on your server.

The first like of your code you will need to include where the nusoap file is like:

include_once "/home/websites/dev/lib/nusoap.php";

Each call to the API basically works like this.

  1. 1) Authenticate
  2. 2) Do what you want
  3. 3) Logout

In order to authenticate we make a call like this:

PHP:
  1. $host = "https://home.azoogleads.com/soap/azads2_server.php";
  2. $soapclient = new nusoap_client($host);
  3.  
  4. $hash = $soapclient->call('authenticate',
  5.     array (
  6.         "affil_id" => $params['ID'],
  7.         "login"    => $params['login'],
  8.         "passhash" => $params['password'],
  9.     )

The above code will give us our authentication "$hash" which we will need from now on in making requests to the API.

Next I want to make a call to the API that will give me all my revenue for today. So here is the code for that:

PHP:
  1. $today=date("Y-m-d");
  2. $money = $soapclient->call('getSubHits',
  3.     array (
  4.         "login_hash" => $hash,
  5.         "affiliate_id"   => $params['ID'],
  6.         "offer_id"   => ALL,
  7.         "start_date" => date("$today"),
  8.         "end_date"   => date("$today"),
  9.                                 "traffic_type_id" => "",
  10.         "sales_only" => true
  11.     )
  12. );
  13. print_r($money);

A couple things. As you can see you can start at a certain time and end at a certain time.

This outputs an array of data something like this (offer ids are changed to prevent saturation ;) ):

Array
(
    [0] => Array
        (
            [hits] => 822
            [leads] => 63
            [amount] => 567.000000
            [sub] => d15
            [offer_id] => 1000
        )

    [1] => Array
        (
            [hits] => 2
            [leads] => 1
            [amount] => 2.350000
            [sub] => altd15
            [offer_id] => 1000
        )

    [2] => Array
        (
            [hits] => 59
            [leads] => 2
            [amount] => 1.000000
            [sub] => alt2d15
            [offer_id] => 1000
        )

    [3] => Array
        (
            [hits] => 66
            [leads] => 1
            [amount] => 9.000000
            [sub] => super
            [offer_id] => 1000
        )

)

There are all kinds of functions you can do... search offers... whatever. Check the official AzoogleAds docs (its in your account) for more specifics.

Now when we are all done we need to logout.

PHP:
  1. $msg = $soapclient->call('logout',
  2. array ("login_hash"=>$hash));

And we are done.

Here is my full script putting everything all together. All you should need to do is download the soap library and input your account information.

PHP:
  1. <?
  2. ################  EDIT THIS ###############
  3. include_once "/path/to/nusoap.php";
  4.  
  5. $loginid='put your username here';
  6. $password='put your password here';
  7. $affid='put your 5 digit affiliate id here';
  8.  
  9. ################  STOP EDITING ############
  10.  
  11. $today=date("Y-m-d");
  12.  
  13. $login_info = array (
  14.     "AZOOGLE" => array ( 'login' => "$loginid", 'password' => "$password", 'ID' => "$affid"), // confirmed
  15. );
  16.  
  17. $params = $login_info['AZOOGLE'];
  18.  
  19. $host = "https://home.azoogleads.com/soap/azads2_server.php";
  20. $soapclient = new nusoap_client($host);
  21.  
  22. $hash = $soapclient->call('authenticate',
  23.     array (
  24.         "affil_id" => $params['ID'],
  25.         "login"    => $params['login'],
  26.         "passhash" => $params['password'],
  27.     )
  28. );
  29.  
  30. if (!$hash) {
  31.     die('no connection to Azoogle');
  32. }
  33.  
  34. echo "Connected to Azoogle ($hash)\n";
  35.  
  36. // now I have the connection ($hash)
  37. // load the sub report
  38.  
  39. //array getSubHits(string login_hash, int affiliate_id, int offer_id, string start_date, string end_date, int traffic_type_id = null, boolean sales_only = null)
  40. // I use affil_id instead of affiliate_id because 'authenticate' function returns the connection handle, so I assume the parameter name is right
  41.  
  42.  
  43. $hits = $soapclient->call('getSubHits',
  44.     array (
  45.         "login_hash" => $hash,
  46.         "affiliate_id"   => $params['ID'],
  47.         "offer_id"   => ALL,
  48.         "start_date" => date("$today"),
  49.         "end_date"   => date("$today"),
  50.                                 "traffic_type_id" => "",
  51.         "sales_only" => true
  52.     )
  53. );
  54.  
  55. // yields empty response all the time
  56.  
  57. print_r($hits);
  58.  
  59. $msg = $soapclient->call('logout',
  60. array ("login_hash"=>$hash));
  61.  
  62. // prints 'Logged out successfully.'
  63. echo $msg;
  64.  
  65.  
  66. ?>

So what can you do with this now? Well you can format the array and pass it to mail so it can email you updates throughout the day. You could get more advanced and set thresholds throughout the day...

If you want to get really badass you could tie it into the Adwords API and crank up or lower your spend on specific keywords based on trends.

APIS ROCK!

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3 out of 5)
Loading ... Loading ...
  1. FF0000
    shamess said on June 26th, 2008 at 5:06 pm

    PHP4? Don’t you think that’s a bit dangerous, now that it’s not even supported?

    [Reply]

  2. FF0000
    Make Money Talks said on June 26th, 2008 at 5:06 pm

    Looking good to use API,
    but sometimes is hard to setup without pro help!

    [Reply]

  3. FF0000
    Andre said on June 26th, 2008 at 5:07 pm

    API == Application Programming Interface
    API != Advanced Programming Interface

    [Reply]

  4. FF0000
    ShoeMoney said on June 26th, 2008 at 5:09 pm

    lol thats probably why I am not a programmer

    [Reply]

  5. FF0000
    Melvin said on June 26th, 2008 at 5:14 pm

    i’m pretty messed up ryt now with API and have been really trying to learn a lot about it…

    [Reply]

  6. FF0000
    john said on June 26th, 2008 at 5:21 pm

    That hurt my brain a little bit! Too much to think about.

    [Reply]

  7. FF0000
    JamiesB said on June 26th, 2008 at 5:21 pm

    Shoe THANKS I just tested and it works perfectly.

    I also was one of those who “some day” was going to do this.

    [Reply]

  8. FF0000
    Winning Startups said on June 26th, 2008 at 6:26 pm

    What the hell are you talking about? That went way over my head!

    [Reply]

  9. FF0000
    Bryn (Internet Is My Life) said on June 26th, 2008 at 6:26 pm

    Hmm interesting, I just signed up with azoogle last week so I’ll have to check this out

    [Reply]

  10. FF0000
    Jack said on June 26th, 2008 at 6:43 pm

    Thanks Jeremy, I started writing PHP web services this month with NuSoap so it’s great to see a real-world example.

    [Reply]

  11. FF0000
    ddn said on June 26th, 2008 at 7:03 pm

    I’m gonna go ahead and guess you’ve never done anything worthwhile in your life.

    [Reply]

  12. FF0000
    v1nce said on June 26th, 2008 at 7:05 pm

    If you want forward compatibility I would definitely suggest staying away from php4 and nusoap. PHP5 has a soap library in core - http://www.php.net/manual/en/ref.soap.php.

    [Reply]

  13. FF0000
    Small Dog breeds said on June 26th, 2008 at 8:04 pm

    confusing to say the least!

    [Reply]

  14. FF0000
    Austin(Cowsgonemadd3) said on June 26th, 2008 at 9:09 pm

    Yeah it looks confusing.

    [Reply]

  15. FF0000
    Sports Picks said on June 26th, 2008 at 9:41 pm

    a nerd post, sweet! :)

    [Reply]

  16. FF0000
    Tom said on June 26th, 2008 at 10:24 pm

    Can you send me the script after you have dillsmack program it to adjust ad spend based on campaign performance? Thanks.

    [Reply]

  17. FF0000
    jatt said on June 26th, 2008 at 10:32 pm

    i joined azoogle ads..but no luck huhu

    [Reply]

  18. FF0000
    Roshan Bhattarai said on June 27th, 2008 at 1:49 am

    Thanks a lot for the code but I think it should also work for PHP5 as well…

    @ v1nce - nusoap client library is easier to use and provide much easier coding to consume and provide web services than the PHP5’s built in soap library…

    [Reply]

  19. FF0000
    Eva White said on June 27th, 2008 at 2:45 am

    Never gone so much in detail into coding before. I guess I’ll just leave that to the pros.

    [Reply]

  20. FF0000
    mcQ said on June 27th, 2008 at 4:41 am

    Thanks for your time to put this one ur site….

    [Reply]

  21. FF0000
    Web Marketeer said on June 27th, 2008 at 5:21 am

    Hahahahah….that’s a bit tough on the poor chap, ain’t it?

    [Reply]

  22. FF0000
    Web Marketeer said on June 27th, 2008 at 5:25 am

    That’s why we love your site, Jeremy. Information like this is priceless. Noe let’s see how well you rank in Google for your keywords, so the whole world can find these instructions when they encounter similar issues with AzoogleAds Soap API.

    [Reply]

  23. FF0000
    Web Marketeer said on June 27th, 2008 at 5:27 am

    #1 on Google for “azoogle ads soap api problems” - excellent!

    [Reply]

  24. FF0000
    Jagdeep said on June 27th, 2008 at 7:11 am

    im sure theres a 3rd party app already available to track your commissions daily

    [Reply]

  25. FF0000
    Tech blog said on June 27th, 2008 at 7:48 am

    Azoogle is not good, they dont accept me :(

    [Reply]

  26. FF0000
    Geiger said on June 27th, 2008 at 8:44 am

    The API has been around for a while. It simply didn’t work for me either. I use .Net though. I’ll have to try it again now and hopefully do a write up for that programming language.

    [Reply]

  27. FF0000
    Tyler Dewitt said on June 27th, 2008 at 8:51 am

    LOL Too funny…

    You could consider your self a programmer because you do have experience with it. It’s just not your thing like you said, but that’s funny. I got a bit humor out of it :).

    [Reply]

  28. FF0000
    PPC said on June 27th, 2008 at 9:58 am

    I am soooo glad I’m not a coder / developer. It all looks like greek to me!

    [Reply]

  29. FF0000
    PPC said on June 27th, 2008 at 10:00 am

    A BIG nerd post too! Dunno how developers can live with all this code. Scary stuff.

    [Reply]

  30. FF0000
    Hustle Strategy said on June 27th, 2008 at 10:05 am

    haha.

    [Reply]

  31. FF0000
    Geiger said on June 27th, 2008 at 10:22 am

    Nerd posts help people out big time. I was looking for examples before and I found zilch! Thanks again shoe.

    [Reply]

  32. FF0000
    Geiger said on June 27th, 2008 at 10:23 am

    Yes, they are very bad at accepting new unproven people. Personally I kept sending them emails until I was accepted. I also named dropped Shoe’s real names and led them to believe we were friends. I didn’t lie about it, just led Azoogle to believe it. It all worked out and last year I brought in over $100,000 in revenue for them.

    [Reply]

  33. FF0000
    Geiger said on June 27th, 2008 at 12:37 pm

    How can you be in PPC and not know a thing about programming?

    [Reply]

  34. FF0000
    Paul said on June 27th, 2008 at 5:10 pm

    No problem at all

    [Reply]

  35. FF0000
    OSx86 said on June 28th, 2008 at 3:19 pm

    APIs Rock indeed, thanks for the details Shoe.

    [Reply]

  36. FF0000
    OSx86 said on June 28th, 2008 at 3:28 pm

    I just joined them too, used Shoes affiliate Link. :)

    [Reply]

  37. FF0000
    OSx86 said on June 28th, 2008 at 3:29 pm

    Easy, just some PHP. :)

    [Reply]

  38. FF0000
    DavidTan said on June 29th, 2008 at 4:44 pm

    na, scripts written in php4 will still continue to run. nothing fancy with the code above too.

    [Reply]

  39. FF0000
    shamess said on June 29th, 2008 at 9:01 pm

    Where’d you get that assumption from? Am I missing something?

    [Reply]

  40. FF0000
    Zak Show said on July 1st, 2008 at 4:40 pm

    ehhggg, that’s too complicated to apply! How do you lean these stuff J ?

    [Reply]

  41. FF0000
    Goran Website said on July 1st, 2008 at 5:22 pm

    I agree with you PPC, its all code to me.

    [Reply]

  42. FF0000
    Goran Website said on July 1st, 2008 at 5:26 pm

    Thats simple, its a marketing position, no need for development.

    [Reply]

  43. FF0000
    Nintendo wii said on July 2nd, 2008 at 3:58 am

    cool working fine. Yes good to use API its rocks. Thanks again for such detail code.

    [Reply]

  44. FF0000
    Binary Ant said on July 3rd, 2008 at 2:35 am

    Cool! I like to work with API’s. You can customize better the appearance, select only the information you want and extend and change the functionality of the standard features :D . I pin this post in my reader in case I apply Azoogle.

    [Reply]

  45. FF0000
    Forumistan said on July 7th, 2008 at 9:29 am

    Man, I hate azoogle…

    [Reply]

  46. [...] on: June 29th, 2008 Shoemoney, John, Chow, Ken McArthur, as well as the whole cast & crew of Top Affiliate Challenge and some [...]

  47. Answers To Questions Round 16 - ShoeMoney® said on October 27th, 2008 at 9:25 am

    [...] If you should pick one affiliate network, which one would it be? ShoeMoney: For me Azoogleads. Their reporting API is the best I have come across and they have the best offers for what we [...]

What do you think? Join the discussion...

How do I change my avatar?

Go to gravatar.com and upload your preferred avatar.