<?php
header("Access-Control-Allow-Origin: *");
header("Content-type:text/html;charset=utf-8");//gb2312
function GetCurl($url){
$curl = curl_init();
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl,CURLOPT_URL, $url);
curl_setopt($curl,CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$resp = curl_exec($curl);
curl_close($curl);
return $resp;
}
$info = GetCurl("http://ip.taobao.com/service/getIpInfo.php?ip=210.75.225.254");
//$info = str_replace("var returnCitySN =","",$info);
//$info = str_replace("};","}",$info);
//echo $info;
//exit;
$info = json_decode($info,false);
if ($info ->code == 0) {
echo $info ->data ->ip."<br/>";
echo $info ->data ->country."<br/>";
} else {
echo '地球';
}
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询