You are here

function smart_ip_get_ipinfodb_url in Smart IP 6.2

Same name and namespace in other branches
  1. 6 smart_ip.module \smart_ip_get_ipinfodb_url()
  2. 7.2 smart_ip.module \smart_ip_get_ipinfodb_url()
  3. 7 smart_ip.module \smart_ip_get_ipinfodb_url()

Get IPInfoDB URL

Parameters

String $ipinfodb_key IPInfoDB key:

String $ip_adress IP address to geolocate:

Interger $version Version number of IPInfoDB service to use:

2 calls to smart_ip_get_ipinfodb_url()
smart_ip_get_location in ./smart_ip.module
Get the geo location from the IP address
smart_ip_requirements in ./smart_ip.install
Implements hook_requirements().

File

./smart_ip.module, line 1274
Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address

Code

function smart_ip_get_ipinfodb_url($ipinfodb_key, $ip_address, $version = 3) {
  if ($version == 3) {

    // Version 3
    return "http://api.ipinfodb.com/v3/ip-city/?key={$ipinfodb_key}&ip={$ip_address}&format=json";
  }
  else {

    // Version 2
    return "http://api.ipinfodb.com/v2/ip_query.php?key={$ipinfodb_key}&ip={$ip_address}&output=json&timezone=false";
  }
}