古詩詞大全網 - 個性簽名 - 微信開發者 對接 ASP代碼

微信開發者 對接 ASP代碼

別聽那些人不會的人瞎扯。

所謂接口, 就是任何語言都可以調用的。並不是只有PHP才能用。

我只能說某些人技術不夠,或者懶得做而已。我的公眾號就是用ASP做的接口。給妳個簡單的參考:

<%@Language="VBScript"?CodePage="65001"%>

<%

'ASP文件以UTF-8的格式保存,否則可能亂碼.

'====================================

'這兩行代碼是為了初期通過微信Token接口驗證的.驗證過後不再使用。

'response.write?request("echostr")

'response.end

'====================================

dim?signature '微信加密簽名

dim?timestamp '時間戳

dim?nonce '隨機數

'dim?echostr '隨機字符串

dim?Token

dim?signaturetmp

token="myweixincode" '您在後臺添寫的?token

signature?=?Request("signature")

nonce?=?Request("nonce")

timestamp?=?Request("timestamp")

dim?ToUserName '開發者微信號

dim?FromUserName'發送方帳號(壹個OpenID)

dim?CreateTime '消息創建時間(整型)

dim?MsgType 'text

dim?wxCont '消息內容

dim?MsgId '消息id,64位整型

Sub?getMSG()

on?error?resume?next

'err.clear

set?xDom?=?Server.CreateObject("MSXML2.DOMDocument")'此處根據您的實際服務器情況改寫

xDom.load?request

ToUserName=xDom.getelementsbytagname("ToUserName").item(0).text

FromUserName=xDom.getelementsbytagname("FromUserName").item(0).text

MsgType=xDom.getelementsbytagname("MsgType").item(0).text

if?MsgType="text"?then?wxCont=xDom.getelementsbytagname("Content").item(0).text

if?MsgType="event"?then?wxCont=xDom.getelementsbytagname("Event").item(0).text

set?xDom=Nothing

End?sub

call?getMSG()

if?FromUserName=""?and?wxCont=""?then?response.end?'無來源和內容,中止處理。

wxCont=replace(wxCont,chr(13),"")

wxCont=replace(wxCont,chr(10),"")

wxCont=trim(wxCont)

function?has(keys)

'on?error?resume?next

dim?ss,i

keys=replace(keys,";",";")

ss=split(keys,";")

for?i=0?to?ubound(ss)

if?instr(?lcase(wxCont),lcase(?ss(i)?)?)>0?then

has=true

exit?function

end?if

next

has=false

end?function

if?wxCont="subscribe"?then?'表示有新的用戶關註,舊接口是Hello2BizUser

reMSG="歡迎關註<吳世昌IT技術服務>"&VBCrLf?&?"?主頁:?"&VBCrLf?&?"www.fj543.com"

elseIf?wxCont="unsubscribe"?Then '取消訂閱

elseIf?wxCont="0"?Then

'處理自定義的回復代碼

reMSG="幫助說明:"?&?VBCrLf?&"回復1查看我們的網址;回復2查看聯系方式;"

elseif?wxCont="1"?then

reMSG="我們的網址:"&VBCrLf?&?"www.fj543.com"

else

reMSG="感謝您的留言,吳世昌IT技術服務團隊將盡快回復,請耐心等候。"

end?if

reMSG=reMSG?&?vbcrlf&?vbcrlf?&?"回復數字0查看幫助說明." '?&?err.description

outXML="<xml>"?&_

"<ToUserName><![CDATA["&fromusername&"]]></ToUserName>"?&_

"<FromUserName><![CDATA["&tousername&"]]></FromUserName>"?&_

"<CreateTime>"&?now()?&"</CreateTime>"?&_

"<MsgType><![CDATA[text]]></MsgType>"?&_

"<Content><![CDATA["?&?reMSG?&?"]]></Content>"?&_

"<FuncFlag>0<FuncFlag>"?&_

"</xml>"

response.write?outXML

%>