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

天气预报接口
北京市天气实况

3℃ 晴

风向风速:西北风2级

相对湿度:27%

空气质量:27优

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

天气预报查询接口支持HTTPS(赠送1000次)

简介:获取全国今天天气及最近7天的天气预报情况

已连接应用数:1679

ASP调用天气查询接口示例:

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

                                        code = "120112"
                                        type = "1"
                                        token = "00d5cb1fac5dc5cbfe2ff218292a2dfd33"    '用户中心查看您的token
                                        url = "https://api.ip138.com/weather/?code="&code&"&type="&type&"&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
                                         %>