AzoogleAds Soap API With PHP4
shoemoney
·
·
4 min read
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) Authenticate
- 2) Do what you want
- 3) Logout
Array
(
=> Array
(
=> 822
=> 63
=> 567.000000
=> d15
=> 1000
)
=> Array
(
=> 2
=> 1
=> 2.350000
=> altd15
=> 1000
)
=> Array
(
=> 59
=> 2
=> 1.000000
=> alt2d15
=> 1000
)
=> Array
(
=> 66
=> 1
=> 9.000000
=> super
=> 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.
$msg = $soapclient->call('logout',
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.
< ?
################ 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;
$host = "https://home.azoogleads.com/soap/azads2_server.php";
$soapclient = new nusoap_client($host);
$hash = $soapclient->call('authenticate',
array (
"affil_id" => $params,
"login" => $params,
"passhash" => $params,
)
);
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,
"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;
?>
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!