现在的位置: 首页运维|语言>正文
获取指定(访客)的IP、地址、邮政编码、国家、经纬度等的信息的API
发表于265 天前 运维|语言 评论数 1 ⁄ 被围观 +

调用方法非常简单。这个也需要数据库来支持。数据库中中文和拼音共存才可以。

<?php
function getIpInfo($ip,$timeout=15) {
    if(!function_exists(’curl_init’) or !function_exists(’simplexml_load_string’)) return false;  

    $ch = curl_init("http://ipinfodb.com/ip_query2.php?ip={$ip}&timezone=true");
    $options = array(
            CURLOPT_RETURNTRANSFER => true,
        );
    curl_setopt_array($ch,$options);
    $res = curl_exec($ch);
    curl_close($ch);  

    if($xml = simplexml_load_string($res)) {
        $return = array();
        foreach ($xml->Location->children() as $key=>$item)  {
            $return[$key] = strtolower($item);
        }
        return $return;
    } else {
        return false;
    }
}
$current_Ip_Info = getIpInfo(’119.7.8.255’);
var_dump($current_Ip_Info);
?>

获取指定(访客)的IP、地址、邮政编码、国家、经纬度等的信息的API:目前有1 条留言

  1. Vicky : 2011年09月14日10:13

    If my porelbm was a Death Star, this article is a photon torpedo.

给我留言


/ 快捷键:Ctrl+Enter
不想听你唠叨×