Heim  >  Artikel  >  Backend-Entwicklung  >  php跟据用户ip获得用户所在地区的接口,该如何解决

php跟据用户ip获得用户所在地区的接口,该如何解决

WBOY
WBOYOriginal
2016-06-13 10:03:13844Durchsuche

php跟据用户ip获得用户所在地区的接口
各位大师们:
  现在需要一个接口,跟据用户ip获得用户所在地区,该怎么做呢?

------解决方案--------------------
你需要一个接口么?可以去大点的公司提供的ip库查找相应的地址(腾讯,sina这样的公司都有提供这样的功能)。
否者你做自己的ip库。

例如sina的ip库

PHP code
<?phpheader ("content-type:text/html;charset=utf-8");$url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=123.127.134.62";$message = json_decode(file_get_contents($url),true);echo "<pre class="brush:php;toolbar:false">";print_r($message);<br><font color="#e78608">------解决方案--------------------</font><br>
探讨

你需要一个接口么?可以去大点的公司提供的ip库查找相应的地址(腾讯,sina这样的公司都有提供这样的功能)。
否者你做自己的ip库。

例如sina的ip库

PHP code
header("content-type:text/html;charset=utf-8");
$url = "http://int.dpool.sina.com.cn/iplookup/iplo……
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn