Page 1 of 1

location api

Posted: Mon Oct 13, 2014 8:05 am
by Vegan
I was looking at ads on my site, I can do better, why limit my ads to USA residents, when tom dick and harry like in canada and the OK

now i already use Google on my site, I know how to take good advantage of their services

I noticed with them they have some location capacility

X-AppEngine-Country:US
X-AppEngine-Region:ca
X-AppEngine-City:norwalk
X-AppEngine-CityLatLong:33.902237,-118.081733

now all I care is country, I am not flogging coffee to a walk by

Code: Select all

<?php 
echo ' Client IP address: '; 
if ( isset($_SERVER["REMOTE_ADDR"]) )    { 
    echo '' . $_SERVER["REMOTE_ADDR"] . ' '; 
} else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) )    { 
    echo '' . $_SERVER["HTTP_X_FORWARDED_FOR"] . ' '; 
} else if ( isset($_SERVER["HTTP_CLIENT_IP"]) )    { 
    echo '' . $_SERVER["HTTP_CLIENT_IP"] . ' '; 
} 
?>
then I realized I had yet another idea come to mind, check to see if a given ad is working on the amazon server, sometimes products are removed

Code: Select all

<!-- http://www.amazon.com/dp/YOUR10DIGITASIN returns http-statuscode=200 if it exists, http-statuscode=404 if it does not -->

Re: location api

Posted: Mon Oct 13, 2014 12:43 pm
by requinix
...Okay?

Re: location api

Posted: Mon Oct 13, 2014 4:36 pm
by Vegan
I was wondering, I guess checking to see if a given AISN is still valid would make sense

Code: Select all

function showAISN(AISN) {
	temp = '<iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=cpa07-20&o=1&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=';
	temp += AISN;
	temp += '" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>';
	document.write(temp+='\n');
}
could I check the AISN with something like an AJAX kind of check or something?

Code: Select all

function showAISN(AISN) {
     if(checkvalid(AISN) {
	temp = '<iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=cpa07-20&o=1&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=';
	temp += AISN;
	temp += '" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>';
	document.write(temp+='\n');
}
}

Re: location api

Posted: Mon Oct 13, 2014 5:11 pm
by requinix
To do what? What's the question?

Re: location api

Posted: Mon Oct 13, 2014 8:13 pm
by Vegan
how to create checkvalid() so that it can skip over a missing product
not sure show how to leverage AJAX

if(stattus (http://www.amazon.com/dp/YOUR10DIGITASIN ) = 200)

is the idea, not sure if JA or PHP should even be used

Re: location api

Posted: Mon Oct 13, 2014 8:17 pm
by requinix
Well you can't AJAX to another domain so there's that, but you can AJAX to your own domain which hosts a script that cURLs the appropriate remote URL.

However you really need to use their API instead of making requests to the website proper. I'm not sure exactly what API we use but the endpoint is http://ecs.amazonaws.com/onca/xml.

Re: location api

Posted: Wed Oct 15, 2014 2:05 pm
by Vegan
At the moment I am using local scripts to manage everything, so I was wonder what I can do to check my ad tables with
this is where I ran across the amazon tool
so I was hoping to leverage that