您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

淘宝ip地址查询类分享(利用淘宝ip库)_PHP教程

2026/2/2 7:44:06发布20次查看
淘宝公司提供了一个很好用的ip地理信息查询接口。在这里:http://ip.taobao.com/
以下这个taobaoipquery类将极大的简化相关的信息查询。
复制代码 代码如下:
m_ip = $ip;
        } else {
            $this->m_ip = ;
        }
        if (!empty($this->m_ip)) {
            $url_handle = curl_init();
            curl_setopt($url_handle, curlopt_url, http://ip.taobao.com/service/getipinfo.php?ip= . $this->m_ip);
            curl_setopt($url_handle, curlopt_returntransfer, true);
            $this->m_content = curl_exec($url_handle);
            curl_close($url_handle);
            if ($this->m_content) {
                $this->m_content = json_decode($this->m_content);
                if ($this->m_content->{'code'} == 1) {
                    exit(query error!);
                }
            } else {
                exit(curl error!);
            }
        } else {
            exit(ip address must be not empty!);
        }
    }
public function get_region() {
        return $this->m_content->{'data'}->{'region'};
    }
public function get_isp() {
        return $this->m_content->{'data'}->{'isp'};
    }
public function get_country() {
        return $this->m_content->{'data'}->{'country'};
    }
public function get_city() {
        return $this->m_content->{'data'}->{'city'};
    }
}
调用很简单
复制代码 代码如下:
$ip = $_server[remote_addr];
$ipquery = new taobaoipquery($ip);
$region = $ipquery->get_region();
$country = $ipquery->get_country();
$city = $ipquery->get_city();
http://www.bkjia.com/phpjc/676912.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/676912.htmltecharticle淘宝公司提供了一个很好用的ip地理信息查询接口。在这里:http://ip.taobao.com/ 以下这个taobaoipquery类将极大的简化相关的信息查询。 复制代码...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product