如何利用IPWHOIS.io提供快速、准确的地理定位数据

149 阅读1分钟

在营销和内容定位的世界里,拥有准确的地理位置数据可能是企业蓬勃发展和陷入困境的区别。 准确的数据就是一切,尤其是在目标营销方面。 当你需要值得信赖的地理位置数据时,IPWHOIS.io是一个很好的来源:快速、可靠、准确

快速点击

  • 免费开始,价格非常有竞争力
  • 提供有关位置、货币、语言等信息
  • 有用的文档和代码样本
  • 快速和安全的有效载荷交付
  • 以CSV、JSON和XML格式提供数据

要使用IPWHOIS,请向他们的API提出请求,将所需的返回格式和用户IP地址作为URL的一部分。

curl http://ipwhois.app/json/8.8.4.4

你的有效载荷将看起来像。

{ "ip": "8.8.4.4″, "success":true, "type": "IPv4″, "continent": "North America", "continent_code":"NA", "country": "United States", "country_code": "US", "country_flag": "cdn.ipwhois.io/flags/us。sv…", "country_capital": "华盛顿", "country_phone": "+1″, "country_neighbours":"CA,MX,CU", "地区": "加利福尼亚", "城市": "山景城", "纬度":37.3860517, "经度":-122.0838511, "asn": "AS15169″, "org": "Google LLC", "isp": "Google LLC", "时区":"America/Los_Angeles", "timezone_name": "太平洋标准时间", "timezone_dstOffset":0, "timezone_gmtOffset":-28800, "timezone_gmt": "GMT -8:00″, "currency": "US Dollar", "currency_code": "USD", "currency_symbol":"$", "currency_rates":1, "currency_plural": "US dollars", "complete_requests":3 }

XML端点提供了一个出色的XML有效载荷。

<?xml version="1.0" encoding="UTF-8"?>
<query>
   <ip>8.8.4.4</ip>
   <success>1</success>
   <type>IPv4</type>
   <continent>North America</continent>
   <continent_code>NA</continent_code>
   <country>United States</country>
   <country_code>US</country_code>
   <country_flag>https://cdn.ipwhois.io/flags/us.svg</country_flag>
   <country_capital>Washington</country_capital>
   <country_phone>+1</country_phone>
   <country_neighbours>CA,MX,CU</country_neighbours>
   <region>California</region>
   <city>Mountain View</city>
   <latitude>37.3860517</latitude>
   <longitude>-122.0838511</longitude>
   <asn>AS15169</asn>
   <org>Google LLC</org>
   <isp>Google LLC</isp>
   <timezone>America/Los_Angeles</timezone>
   <timezone_name>Pacific Standard Time</timezone_name>
   <timezone_dstOffset>0</timezone_dstOffset>
   <timezone_gmtOffset>-28800</timezone_gmtOffset>
   <timezone_gmt>GMT -8:00</timezone_gmt>
   <currency>US Dollar</currency>
   <currency_code>USD</currency_code>
   <currency_symbol>$</currency_symbol>
   <currency_rates>1</currency_rates>
   <currency_plural>US dollars</currency_plural>
   <completed_requests>8</completed_requests>
</query>

你也可以指定一个你想在有效载荷中的字段的选择集合。

// http://ipwhois.app/json/8.8.4.4?objects=country,city,timezone
{
  "country": "United States",
  "city": "Mountain View",
  "timezone": "America/Los_Angeles"
}

使用lang 参数,你可以得到本地化的位置信息。

ipwhois.app/json/8.8.4.…

另一个了不起的好处是能够使用JSONP。

$.ajax({
	method: 'GET',
	contentType: 'application/json',
	url: 'http://ipwhois.app/json/' + ip,
	dataType: 'json',
	success: function(json) {
	    // Country code output, field "country_code"
	    console.log(json.country_code);
	}
});

IPWHOIS.io是一个超级简单、有用的服务,可以帮助你根据用户的位置定制你的广告和内容,这反过来可以大大提高你的转换机会和用户满意度。 当你需要准确、快速的地理位置信息时,请看一下IPWHOIS.io!