微信公众号自定义接口关键词触发第三方接口详细代码

2025-04-27 20:34:59
推荐回答(1个)
回答1:

<% 
'#################################
'#通过POST  raw/xml格式数据通讯           #
'#################################

'#编码得是utf-8 #
Cset="utf-8"

'#容错 #
On Error Resume Next

'#禁止缓存 #
Response.Buffer = True 
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache"

'#post aw/xml 函数 #
Function PostHttpPage(RefererUrl,PostUrl,PostData) 
     Dim xmlHttp 
     Dim RetStr      
     Set xmlHttp = CreateObject("Msx" & "ml2.XM" & "LHT" & "TP") 
     xmlHttp.Open "POST", PostUrl, False
     XmlHTTP.setRequestHeader "Content-Length",Len(PostData) 
     xmlHttp.setRequestHeader "Content-Type", "raw/xml"
     xmlHttp.setRequestHeader "Referer", RefererUrl
     xmlHttp.Send PostData 
     If Err.Number <> 0 Then 
         Set xmlHttp=Nothing
         PostHttpPage = "$False$"
         Exit Function
     End If
     PostHttpPage=bytesToBSTR(xmlHttp.responseBody,Cset)
     Set xmlHttp = nothing
End Function
'作  用:将获取的源码转换为中文
Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText 
objstream.Close
set objstream = nothing
End Function

city = DateDiff("s", "01/01/1970 00:00:00", Now())

resp = PostHttpPage(“转发目标网址”,"转发目标网址","接收到的完整xml")

response.write ""&resp 
%>