求教:查询手机号码归属地,淘宝的接口,返回的数据应该如何避免

WBOY
Release: 2016-06-13 11:58:57
Original
1432 people have browsed it

求教:查询手机号码归属地,淘宝的接口,返回的数据应该如何处理
http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=15850781443

直接用file_get_contents 返回结果是这样的

<br />__GetZoneResult_ = {<br />    mts:'1585078',<br />    province:'江苏',<br />    catName:'中国移动',<br />    telString:'15850781443',<br />	areaVid:'30511',<br />	ispVid:'3236139',<br />	carrier:'江苏移动'<br />}<br />
Copy after login


应该采用什么方式使用这个接口?

如果直接使用这个file_get_contents 得到的结果应该如何处理 才能得到 归属地?
------解决方案--------------------
返回的是一句 js 语句
在 php 中使用的话可以这样解析
$s = file_get_contents('http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=15850781443');<br />preg_match_all("/(\w+):'([^']+)/", $s, $m);<br />$a = array_combine($m[1], $m[2]);<br />print_r($a);<br />
Copy after login
Array
(
    [mts] => 1585078
    [province] => 江苏
    [catName] => 中国移动
    [telString] => 15850781443
    [areaVid] => 30511
    [ispVid] => 3236139
    [carrier] => 江苏移动
)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template