location api

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

location api

Post 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 -->
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: location api

Post by requinix »

...Okay?
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: location api

Post 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');
}
}
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: location api

Post by requinix »

To do what? What's the question?
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: location api

Post 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
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: location api

Post 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.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: location api

Post 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
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply