Home > php教程 > PHP源码 > Query details by IP address

Query details by IP address

WBOY
Release: 2016-08-04 08:53:34
Original
1829 people have browsed it
Jump to [1] [2] [3] [Full screen preview]
地址:http://www.bunian.cn/gongjv/ip/?ip=IP地址
Copy after login

2. [Code]Return Parameters Jump to [1] [2] [3] [Full screen preview]

{
    "ip": "218.12.41.188", //IP地址
    "address": "中国河北省石家庄市",//详细地址
    "state": "中国",//所属国家,国外IP默认英文
    "province": "河北省",//省
    "city": "石家庄市",//市
    "district": "",//区
    "longitude": 114.52208184,//经度
    "latitude": 38.04895831,//纬度
    "status": 0 //错误返回1
}
Copy after login

3. [Code]Source code example Jump to [1] [2] [3] [Full screen preview]

$ip = @$_GET['ip'];
		$url ="http://www.bunian.cn/gongjv/ip/?ip={$ip}";
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
		$data = curl_exec($ch);
		curl_close($ch);
		$ipinfo = json_decode($data,true);
		
		$ipinfo['ip']//IP地址
		$ipinfo['address'] //详细信息
		$ipinfo['state']//国家
		$ipinfo['province']//城市
		$ipinfo['city']//地区
		$ipinfo['longitude']//经度
		$ipinfo['latitude']//纬度
 
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template