|
HTTP API Access
Getting StartedTo use the API you need to register a FREE account with GoNew. Once you have done that you can access your Control Panel and Setup Your API Access.
After your API access has been setup, you need to make a note of your GoNew AccountID and the API Access Key. These to details are used to authenticate you API calls to our server.
Additionally, you can also setup an IP Lock to restrict API calls. So that the calls can only be made from certain IP addresses. (EG: the IP address of your Webserver)
HTTP API Specification :Currently the is only one api command, implemented. ip2c: This is the command to obtain country code and country name from an IP address.
Syntax: http://api.gonew.co.uk/ip2c/ip2c.php?u=AccountID&k=APIKEY&ip=IPADDRESS
Parameters: u = Your GoNew Account ID k = Your IP To Country API Access Key ip = The IP address to lookup
Return Values: On success the results returned are in the following format: OK:\n
Where ip is the ip that was sent in the request, countrycode is the 2 letter ISO3166 uppercase code for the country (EG: US), countryname is the full country name in uppercase (EG: UNITED STATES).
On error the results returned are in the following format: ERR: errornumber, errordescription\n
Possible Error Codes
Example PHP Code:<?php
$u='GN000000'; //replace with your AccountID
$k='67eb6209d68c7fcee6a4313455d7a652'; //replace with your API key
$ip=$_SERVER['REMOTE_ADDR'];
$result = file_get_contents("http://api.gonew.co.uk/ip2c/ip2c.php?u=$u&k=$k&ip=$ip");
if ($result && strpos($result,"OK:\n")===0) {
//success
$bits=explode('|',$result);
echo("IP: $ip - Country Code: $bits[1] Country Name: $bits[2]");
} else if ($result) {
//error reported from server
echo($result);
} else {
//Failed to connect to server
echo("Failed to connect to server");
}
?>
|
|||||||||||||||||||||||||||||||||||