/**
     * 获取ip城市信息
     * CreateBy XueSong
     * @param string $ip
     * @return array|bool|mixed
     */
    function getCity($ip = '')
    {
        if($ip == ''){
            $url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json";
            $ip=json_decode(file_get_contents($url),true);
            $data = $ip;
        }else{
            $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;
    }

 

相关文章:

  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
  • 2022-01-13
猜你喜欢
  • 2021-09-02
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2021-07-27
相关资源
相似解决方案