Determine Users Country

Hi,

I’m trying to figure out the users country. I know we can get latitude and longitude, but then what would I do with the coordinates? I don’t want to have a huge database of all possible countries. I only really need to check for the following countries:

USA
UK
Australia

I’m doing this so that I can use the appropriate iTunes Affiliate Links in each country. Would there be an easy way of doing this? My app does NOT use location otherwise, it would only be to determine which links the app would redirect them too. [import]uid: 51654 topic_id: 17709 reply_id: 317709[/import]

please check google geocoding api, especially reverse geocoding section…

http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding

After issuing some simple url requests and parsing response, one can easily determine country codes from geo coordinates. [import]uid: 11686 topic_id: 17709 reply_id: 67507[/import]

Thanks for the link. I noticed that their site says

“Use of the Google Geocoding API is subject to a query limit of 2,500 geolocation requests per day.”

So after hitting 2500, I’d have to pay for additional requests? That would be extremely costly for me. I expect to go way over that amount.

Would their be an easier way with just a couple “if” statements maybe to check the latitude and longitude? Since I only need a few countries, that might work… [import]uid: 51654 topic_id: 17709 reply_id: 67511[/import]

Could you use something like this, http://ipinfodb.com/ip_location_api_json.php

Just fire off a request and it will return a json response with the details. The rate limit is 1 request every 2 seconds, I don’t know how popular your app is, but this sounds reasonable as I guess you would only need to run the request the very first time the app is run and then you could cache the results to a file for future use. [import]uid: 36590 topic_id: 17709 reply_id: 67515[/import]