首页 > 移动平台 > 详细

手机号码归属地查询php函数

时间:2020-02-03 18:41:49      阅读:75      评论:0      收藏:0      [点我收藏+]

  手机号码归属地查询php函数

function tel_location($ip) {
$u = “https://www.youdao.com/smartresult-xml/search.s?type=mobile&q=$ip”;
$r = HttpRequest($u);
preg_match(“#<location>(.+)</location>#Ui”, $r, $m);
return iconv(“GBK”, “UTF-8//IGNORE”, strval($m[1]));
//echo strval($m[1]);
}

function HttpRequest($url) {
if ( !function_exists(‘curl_init’) ) { return “<location>暂未能查询到</location>”; }
$timeout = 2;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
$result = curl_exec($ch);
return $result;
}

  

手机号码归属地查询php函数

原文:https://www.cnblogs.com/68xi/p/12256433.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!