使用人数:123人
IP归属地查询

  1. 接口介绍:查询指定IP地址的归属地
  2. 接口地址: http://open-api-developer.luzhi.online/getIpLocation
  3. 请求方式: GET
  4. 返回格式: JSON
  5. 请求参数说明:
    名称 必须 类型 说明
    token String 接口调用授权签名
    ip 必须 String ip地址
  6. 请求示例:
    http://open-api-developer.luzhi.online/getIpLocation?ip=223.5.5.5&token=***
  7. 返回参数:
    名称 类型 说明
    code int 响应码。成功为200,其余参见接口调用响应码表
    msg String 返回消息。成功返回Succeed。其余错误消息为对应错误码的提示。
    data Object 返回数据。数据类型为Json格式的Object
    data数据说明:
    code int 状态码
    message String 返回消息
    data Object 返回数据
  8. 正确返回示例:
    {
    	"code": 200,
    	"message": "Succeed",
    	"data": {
    		"country": "ALIDNS.COM",
    		"province": "",
    		"city": "",
    		"district": "",
    		"town": "",
    		"telecom": "阿里云",
    		"ipaddr": "223.5.5.5"
    	}
    }
  9. 错误返回示例:
    {
      "code": 401,
      "message": "Sign is error",
      "data": null
    }
  10. 参考代码:

    
            //using System.IO;
            //using System.Text;
            //using System.Net;
            //using System.Net.Security;
            static void Main(string[] args)
            {
                String method = "GET";
                String url = "http://open-api-developer.luzhi.online/getIpLocation?ip=223.5.5.5&token=***";
                HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url); 
                httpRequest.Method = method;
                try
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                    Stream st = httpResponse.GetResponseStream();
                    StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
                    Console.WriteLine(reader.ReadToEnd());
                    Console.WriteLine("\n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
                                                 

     
         
        public static void main(String[] args) throws IOException
        { 
            String url = "http://open-api-developer.luzhi.online/getIpLocation?ip=223.5.5.5&token=***";
        
            HttpClient httpClient = HttpClients.custom().build();
            HttpGet get = new HttpGet(url);
        
            HttpResponse response = httpClient.execute(get);
            HttpEntity resp_entity = response.getEntity();
            resp_entity.getContent();
        
            String resp_content = EntityUtils.toString(resp_entity,StandardCharsets.UTF_8);
        
            System.out.println(resp_content);
        } 
                                             

    
        import json, urllib
        from urllib import urlencode
    
        url = "http://*****"
        params = { 
            "token": "*************",     # 授权签名 
            "param1":"……"               # 参数1                                       
        }
        params = urlencode(params)
        f = urllib.urlopen(url, params)
        content = f.read()
        res = json.loads(content)
        if res:
            print(res)
        else:
            print("请求异常")