这是原创程序,早年的。PHP 5.2版本,更高版本未测试,如果环境不一样,可以只下载后提取mysql自行开发查询前端。
修改config\database.php 内的数据库连接就可以了,建立相应的数据表。
本手机号码查询接口使用高速缓存系统,二次查询速度提升500%。
返回数据为JSON
你的域名/index.php?mobile=手机号
/**
* 获取手机号码所在地
* @param int $mobile 待查询的手机号码
*/
function get_mobile_area($mobile){
if (isset($mobile)) {
if(empty($mobile) && !is_int($mobile)) return false;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '你的域名/index.php?mobile='.$mobile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
if($data) return get_object_vars(json_decode($data));
return false;
}
}