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]
$host = “https://home.azoogleads.com/soap/azads2_server.php”;
$soapclient = new nusoap_client($host);

$hash = $soapclient->call(‘authenticate’,
array (
“affil_id” => $params[‘ID’],
“login” => $params[‘login’],
“passhash” => $params[‘password’],
)
[/php]

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]
$today=date(“Y-m-d”);
$money = $soapclient->call(‘getSubHits’,
array (
“login_hash” => $hash,
“affiliate_id” => $params[‘ID’],
“offer_id” => ALL,
“start_date” => date(“$today”),
“end_date” => date(“$today”),
“traffic_type_id” => “”,
“sales_only” => true
)
);
print_r($money);
[/php]

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]

$msg = $soapclient->call(‘logout’,
array (“login_hash”=>$hash));
[/php]

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]
< ? ################ EDIT THIS ############### include_once "/path/to/nusoap.php"; $loginid='put your username here'; $password='put your password here'; $affid='put your 5 digit affiliate id here'; ################ STOP EDITING ############ $today=date("Y-m-d"); $login_info = array ( "AZOOGLE" => array ( ‘login’ => “$loginid”, ‘password’ => “$password”, ‘ID’ => “$affid”), // confirmed
);

$params = $login_info[‘AZOOGLE’];

$host = “https://home.azoogleads.com/soap/azads2_server.php”;
$soapclient = new nusoap_client($host);

$hash = $soapclient->call(‘authenticate’,
array (
“affil_id” => $params[‘ID’],
“login” => $params[‘login’],
“passhash” => $params[‘password’],
)
);

if (!$hash) {
die(‘no connection to Azoogle’);
}

echo “Connected to Azoogle ($hash)\n”;

// now I have the connection ($hash)
// load the sub report

//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)
// I use affil_id instead of affiliate_id because ‘authenticate’ function returns the connection handle, so I assume the parameter name is right

$hits = $soapclient->call(‘getSubHits’,
array (
“login_hash” => $hash,
“affiliate_id” => $params[‘ID’],
“offer_id” => ALL,
“start_date” => date(“$today”),
“end_date” => date(“$today”),
“traffic_type_id” => “”,
“sales_only” => true
)
);

// yields empty response all the time

print_r($hits);

$msg = $soapclient->call(‘logout’,
array (“login_hash”=>$hash));

// prints ‘Logged out successfully.’
echo $msg;

?>
[/php]

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!

By Jeremy Schoemaker

Jeremy "ShoeMoney" Schoemaker is the founder & CEO of ShoeMoney Media Group, and to date has sold 6 companies and done over 10 million in affiliate revenue. In 2013 Jeremy released his #1 International Best selling Autobiography titled "Nothing's Changed But My Change" - The ShoeMoney Story. You can read more about Jeremy on his wikipedia page here.

48 thoughts on “AzoogleAds Soap API With PHP4”
  1. PHP4? Don’t you think that’s a bit dangerous, now that it’s not even supported?

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

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

  4. Shoe THANKS I just tested and it works perfectly.

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

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

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

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

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

  9. 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…

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

  11. 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.

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

  13. 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.

  14. 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 :).

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

  16. 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.

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

  18. Top Affiliate Challenge Contestants Get Their Party On! | Peanuts to Profits With Thor Schrock says:

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

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

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

  21. 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 😀 . I pin this post in my reader in case I apply Azoogle.

  22. […] 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 […]

  23. Seems like Azoogle can’t provide proper support for this API. Does any one know who can give me some answers regarding stuff I’d like to do with the API?

    I’m a programmer, so it’s not like I need private lessons or anything, but there are some variables that are unexplained, and some obvious functionality that is either missing or not included in the documentation provided by Azoogle….

    I asked my AM, but he could help or find anyone else who could (which is kind f annoying…. why give an API if you can’t support it?)

Comments are closed.