PHP根据手机号获取归属地
2015-03-19 13:47
169 查看
$doc = new DOMDocument(); $filepath="http://life.tenpay.com/cgi-bin/mobile/MobileQueryAttribution.cgi?chgmobile=15238275006";//返回数据为xml格式的 $doc->load($filepath);
//解析xml数据,得到需要的数据,这里我只需要得到省市,即可 $books = $doc->getElementsByTagName("root"); foreach($books as $book) { <span style="white-space:pre"> </span>$provinces = $book->getElementsByTagName("province"); $province = $provinces->item(0)->nodeValue; $citys = $book->getElementsByTagName("city"); $city = $citys->item(0)->nodeValue; $usercity=trim($province).",".trim($city); }
下面为返回数据格式
<?xml version="1.0" encoding="gb2312" ?> - <root> <ENV_CgiName>/cgi-bin/mobile/MobileQueryAttribution.cgi</ENV_CgiName> <ENV_ClientAgent>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; .NET CLR 1.1.4322; InfoPath.2; Tablet PC 2.0)</ENV_ClientAgent> <ENV_ClientIp>117.85.147.186</ENV_ClientIp> <ENV_QueryString>chgmobile=15238275006</ENV_QueryString> <ENV_RequestMethod>GET</ENV_RequestMethod> <ENV_referer>http://write.blog.csdn.net/postedit</ENV_referer> <chgmobile>15238275006</chgmobile> <city>平顶山</city> <province>河南</province> <retcode>0</retcode> <retmsg>OK</retmsg> <supplier>移动</supplier> <tid /> </root>
相关文章推荐
- PHP--根据手机号-淘宝平台获取归属地运营商信息
- PHP获取手机号归属地,PHP获取2017最新手机号段属地类
- java根据手机号获取归属地
- php根据手机号码获取归属地|所在地区
- 根据手机号获取号码归属地
- PHP 根据IP地址获取所在城市
- PHP通过API获取手机号码归属地
- 手机号获取归属地 获取到到城市
- php 根据IP地址获取所在城市
- php根据年月获取季度的方法
- PHP 根据IP地址获取所在城市
- php根据给定日期获取给定日期本周的日期
- 根据银行卡账号获取所属银行php
- PHP实现根据时间戳获取周几的方法
- PHP获取IP地址及根据IP判断城市实…
- php根据某年某月获取该月天数
- 利用webservice获取所有手机号归属地
- php根据地理坐标获取国家、省份、城市,及周边数据类
- 获取手机号运营商及归属地的免费API
- php根据某年某月获取该月天数