通过API接口 获取 IP 跟 手机 所在地信息
2013-03-15 11:28
218 查看
/* 传入手机号码,通过API的到xml格式数据,对xml进一步解析,最后返回相应的号码信息的数组。*/ function getCity_tel($phonenumber) { /* 注释掉的是调用的淘宝的API */ /*$url = "http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=".$phonenumber; $ret = iconv('GBK','UTF-8',file_get_contents($url)); $ret = str_replace('__GetZoneResult_ = ','',$ret); $ret = str_replace("'",'"',$ret); $ret = str_replace(" ",'',$ret); $ret = str_replace('{','{"',$ret); $ret = str_replace(":",'":',$ret); $ret = str_replace(",",',"',$ret); $ret = preg_replace("/\s/",'',$ret); $tel = json_decode($ret);*/ /* 这里调用的是有道的API */ $data = array(); $url = "http://www.yodao.com/smartresult-xml/search.s?type=mobile&q=".$phonenumber; $tel = simplexml_load_string(file_get_contents($url)); $data['phonenum'] = (string)$tel->product->phonenum; $data['location'] = explode(" ",(string)$tel->product->location); return $data; } /* 传入IP地址,通过API的到JSON格式数据,对JSON进一步解析,最后返回相应的IP地址的数组。*/ function getCity_ip($ip) { /* 这里调用的是淘宝的API */ $url="http://ip.taobao.com/service/getIpInfo.php?ip=".$ip; $ip=json_decode(file_get_contents($url)); if((string)$ip->code=='1'){ return false; } $data = (array)$ip->data; return $data; }
直接调用返回的都是数组,直接处理数组就可以得到想到的信息了
相关文章推荐
- 淘宝IP地址库API接口 (PHP)通过ip获取地址信息
- 淘宝IP地址库API接口(PHP)通过ip获取地址信息
- 【小功能2】android获取手机信息(号码,内存,CPU,分辨率,MAC,IP,SD卡,IMEI,经纬度,信号强度等等)
- Linux 网络编程之通过IP或者主机名获取信息
- android通过手机本身来获取经纬度等信息(不使用第三方地图)
- Android通过获取Ip的方法判断手机是否联网
- 使用 python 获取 Linux 的 IP 信息(通过 ifconfig 命令)
- 实现pc端通过usb获取到android手机上的短信、通讯录等信息
- 通过GeoIP2分析访问者IP获取地理位置信息
- Android基站定位——通过手机信号获取基站信息(一)
- PHP获取用户IP所在地的信息
- android 获取手机信息(device ip,os version etc.)
- 【小功能2】android获取手机信息(号码,内存,CPU,分辨率,MAC,IP,SD卡,IMEI,经纬度,信号强度等等)
- 通过GeoIP2分析访问者IP获取地理位置信息
- 通过GeoIP2分析访问者IP获取地理位置信息
- 通过IP获取地理位置信息的几种方式
- Java工具类之通过IP获取对应的位置信息及网络供应商
- 通过GeoIP2分析访问者IP获取地理位置信息
- 通过JAVA代码获取手机的一些基本信息(本机号码,SDK版本,系统版本,手机型号)
- Android小功能获取手机信息(号码,内存,CPU,分辨率,MAC,IP,SD卡,IMEI,经纬度,信号强度等等)