A quick article just as a note to get the users country information from a third-party API based on the given IP address.
How?
Well this is just a list of free 3rd-party APIs and the below code is dependent on these being online and working...
The quickest I found [limit 1000 per day | Incorrect Location]:
copyraw
	
v_Url = "http://api.db-ip.com/v2/free/"+ zoho.ipaddress; v_Response = getUrl( v_Url );
- v_Url = "http://api.db-ip.com/v2/free/"+ zoho.ipaddress;
- v_Response = getUrl( v_Url );
Returns something like:
copyraw
	
{
    "ipAddress": "147.188.254.175",
    "continentCode": "EU",
    "continentName": "Europe",
    "countryCode": "GB",
    "countryName": "United Kingdom",
    "stateProv": "England",
    "city": "Birmingham (Edgbaston)"
}
	- {
- "ipAddress": "147.188.254.175",
- "continentCode": "EU",
- "continentName": "Europe",
- "countryCode": "GB",
- "countryName": "United Kingdom",
- "stateProv": "England",
- "city": "Birmingham (Edgbaston)"
- }
A more comprehensive alternative [Limit 150 per minute | not for commercial use]:
copyraw
	
v_Url = "http://ip-api.com/json/"+ zoho.ipaddress;
v_Response = getUrl( v_Url );
// usage: v_TimeZone = v_Response.getJSON("timezone");
	- v_Url = "http://ip-api.com/json/"+ zoho.ipaddress;
- v_Response = getUrl( v_Url );
- // usage: v_TimeZone = v_Response.getJSON("timezone");
Returns something like:
copyraw
	
{
    "query": "147.188.254.175",
    "status": "success",
    "continent": "Europe",
    "continentCode": "EU",
    "country": "United Kingdom",
    "countryCode": "GB",
    "region": "ENG",
    "regionName": "England",
    "city": "Birmingham",
    "district": "",
    "zip": "B15",
    "lat": 52.4666,
    "lon": -1.9205,
    "timezone": "Europe/London",
    "isp": "University of Birmingham",
    "org": "The University of Birmingham",
    "as": "AS786 Jisc Services Limited",
    "asname": "JANET",
    "mobile": false,
    "proxy": false
}
	- {
- "query": "147.188.254.175",
- "status": "success",
- "continent": "Europe",
- "continentCode": "EU",
- "country": "United Kingdom",
- "countryCode": "GB",
- "region": "ENG",
- "regionName": "England",
- "city": "Birmingham",
- "district": "",
- "zip": "B15",
- "lat": 52.4666,
- "lon": -1.9205,
- "timezone": "Europe/London",
- "isp": "University of Birmingham",
- "org": "The University of Birmingham",
- "as": "AS786 Jisc Services Limited",
- "asname": "JANET",
- "mobile": false,
- "proxy": false
- }
List of Free APIs with GeoLocation services:
Just append the IP address to the end of these to test.
- https://extreme-ip-lookup.com/json/
- http://ip-api.com/json/
- http://ipinfo.io/json/
- http://api.db-ip.com/v2/free/
Category: Zoho :: Article: 682
	

 
						  
                 
						  
                 
						  
                 
						  
                 
						  
                 
 
 

 
 
Add comment