联系客服: iP138.com客服 iP138客服 |

iP查询接口
  • API接口QQ交流群:177096428   iP138 api接口
  • 数据修正QQ处理群:94181690    iP138数据修正

iP查询接口支持HTTPS(赠送1000次)

简介:获取iP地址对应的省市区以及运营商名称

已连接应用数:25107

国内:网宿cdn; 国际:亚洲中国香港、韩国首尔、日本东京、新加坡、欧洲德国法兰克福、北美洲美国硅谷节点

接口地址

http协议:http://api.ip138.com/ipv4/
https协议:https://api.ip138.com/ipv4/

* API接口可能会因为各种网络原因和攻击都可能产生阻断,请开发时做好冗余和异常处理

* 当HTTP请求返回的状态码非200时,请做异常处理,比如 202 状态码造成的原因可能是无效Token、余额不足、格式错误

ASP调用iP查询接口示例:

方法一

                                        <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
                                        <% Option Explicit
                                        '=========================================================
                                        ' File      : .asp
                                        ' Version   : 1.0.0.0
                                        ' Create    : 
                                        ' Modify    : 
                                        '=========================================================
                                        ' 1.0.0.0   : 
                                        '========================================================= %>
                                        <% Dim ip,datatype,token,url

                                        ip = "117.25.13.123"
                                        datatype = "txt"
                                        token = "00d5cb1fac5dc5cbfe2ff218292a2dfd33"    '用户中心查看您的token
                                        url = "https://api.ip138.com/ipv4/?ip="&ip&"&datatype="&datatype&"&token="&token

                                        Response.Write (GetURL(url))

                                        Function GetURL(url)
                                            on error resume next
                                            dim Retrieval
                                            Set Retrieval = Server.CreateObject("MSXML2.ServerXMLHTTP")
                                                    Retrieval.setTimeouts 600000, 600000, 600000, 600000
                                                    Retrieval.Open "GET", url, false
                                                    Retrieval.Send
                                                    GetURL = Retrieval.ResponseBody
                                            Set Retrieval = Nothing
                                            GetURL=BytesToBstr(GetURL,"utf-8")
                                        End Function

                                        Function BytesToBstr(strBody,CodeBase)
                                                dim objStream
                                                set objStream = Server.CreateObject("Adodb.Stream")
                                                objStream.Type = 1
                                                objStream.Mode =3
                                                objStream.Open
                                                objStream.Write strBody
                                                objStream.Position = 0
                                                objStream.Type = 2
                                                objStream.Charset = CodeBase
                                                BytesToBstr = objStream.ReadText 
                                                objStream.Close
                                                set objStream = nothing
                                        End Function
                                         %>
                                    

方法二

                                        <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
                                        <% Option Explicit
                                        '=========================================================
                                        ' File      : .asp
                                        ' Version   : 1.0.0.0
                                        ' Create    : 
                                        ' Modify    : 
                                        '=========================================================
                                        ' 1.0.0.0   : 
                                        '========================================================= %>
                                        

                                        <% Dim ip,datatype,token,url,strMid,oid,sign
                                        ip = "117.25.13.123"
                                        strMid = 777    '用户中心查看您的mid
                                        oid = 777   '用户中心查看您的oid
                                        datatype = "txt"
                                        token = "00d5cb1fac5dc5cbfe2ff218292a2dfd33"    '用户中心查看您的token
                                        url = "https://api.ip138.com/ipv4/?"
                                        sign = MD5_32("ip="&ip&"&token="&token)
                                        %>

                                        <script type="text/javascript">
                                        
                                        </script>
                                        <script type="text/javascript" src="<%= url&"ip="&ip&"&callback=find&mid="&strMid&"&oid="&oid&"&sign="&sign %>"></script>