zoukankan      html  css  js  c++  java
  • 淘宝IP地址库API接口(PHP)通过ip获取地址信息

    淘宝IP地址库网址:http://ip.taobao.com/

    淘宝地址库API接口

    提供的服务包括:
    1. 根据用户提供的IP地址,快速查询出该IP地址所在的地理信息和地理相关的信息,包括国家、省、市和运营商。
    2. 用户可以根据自己所在的位置和使用的IP地址更新我们的服务内容。

    接口说明:
    1. 请求接口(GET方式):
    http://ip.taobao.com/service/getIpInfo.php?ip=[ip地址字串]

    2. 响应信息(json格式数据):
    国家 、省(自治区或直辖市)、市(县)、运营商

    3. 返回数据格式:

    {"code":0,"data":{"ip":"210.75.225.254","country":"u4e2du56fd","area":"u534eu5317",
    "region":"u5317u4eacu5e02","city":"u5317u4eacu5e02","county":"","isp":"u7535u4fe1",
    "country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
    "county_id":"-1","isp_id":"100017"}}
    其中code的值的含义为,0:成功,1:失败。

    4. PHP代码示例:

    function getCity($ip)
    {
    $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;
    }
    $ip='221.216.64.183';
    print_r(getCity($ip));exit;
  • 相关阅读:
    审核系统
    ehcache 缓存
    tomcat 内存设置
    html5 开发 跨平台 桌面应用
    service thread 结合使用
    html5桌面应用
    鼠标 事件
    服务器 判断 客户端 文件下载
    使用github管理Eclipse分布式项目开发
    uub代码
  • 原文地址:https://www.cnblogs.com/wawahaha/p/3546189.html
Copyright © 2011-2022 走看看