php json操作 获取ip地理位置

v2016 2019-4-16 2101


这是求助帖

api

http://ws.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx/getCountryCityByIp?theIpAddress=127.0.0.1


求c大写个简单的样例,json操作不会。。。

最新回复 (1)
  • C 2019-4-16
    2
    你这页面返回的根本不是json……
    如果是json的话,假设页面地址是:
    http://abc.com/1.php
    那先把页面内容读取进变量:
    $page=file_get_contents(‘http://abc.com/1.php’);
    然后再json解码成数组:
    $arr=json_decode($page,true);
    后面那个true有时改成false才能正确解析,自己试试看哪个能用。
    解析后就按数组用了。
返回
发新帖