0
点赞
收藏
分享

微信扫一扫

通过ip地址获取ip地址的区域信息

非宁静不致远 2022-10-11 阅读 119

function​ 
​getcposition(​
​$ip​
​){






try​
​{



$res1​
​= ​
​file_get_contents​
​(​
​"http://ip.taobao.com/service/getIpInfo.php?ip=$ip"​
​);



$res1​
​= json_decode(​
​$res1​
​,true);






if​
​(​
​$res1​
​[ ​
​"code"​
​]==0){



return​
​$res1​
​[​
​'data'​
​][​
​"country"​
​].​
​$res1​
​[​
​'data'​
​][ ​
​"region"​
​].​
​$res1​
​[​
​'data'​
​][​
​"city"​
​].​
​"_"​
​.​
​$res1​
​[​
​'data'​
​][ ​
​"isp"​
​];



}​
​else​
​{



return​
​"未能获取"​
​;



}



}​
​catch​
​(Exception ​
​$e​
​){



return​
​"未能获取"​
​;



}


}

举报

相关推荐

0 条评论