微信token验证问题

<!--#include file="lib/sha1.asp"-->
<%
token = "weixin"
signature = Request("signature")
nonce = Request("nonce")
timestamp = Request("timestamp")
echostr=request("echostr")

If echostr <> "" then
str = ""
Myarray=Sort(Array(token,timestamp,nonce))
set stm=server.CreateObject("adodb.stream")
stm.Type=2 '以本模式读取
stm.mode=3
stm.open
stm.WriteText token&"\n"×tamp&"\n"&nonce
stm.SaveToFile server.MapPath("log.txt"),2
stm.flush
stm.Close
set stm=nothing
For M=0 To Ubound(Myarray)
str=str&Myarray(M)
Next
if signature=Lcase(sha1(str)) then
response.Write(echostr)
response.end
end if
else
set stm=server.CreateObject("adodb.stream")
stm.Type=2 '以本模式读取
stm.mode=3
stm.open
stm.WriteText "失败"
stm.SaveToFile server.MapPath("log.txt"),2
stm.flush
stm.Close
set stm=nothing
End if

Function Sort(ary)
Dim KeepChecking,I,FirstValue,SecondValue
KeepChecking = TRUE
Do Until KeepChecking = FALSE
KeepChecking = FALSE
For I = 0 to UBound(ary)
If I = UBound(ary) Then Exit For
If ary(I) > ary(I+1) Then
FirstValue = ary(I)
SecondValue = ary(I+1)
ary(I) = SecondValue
ary(I+1) = FirstValue
KeepChecking = TRUE
End If
Next
Loop
Sort = ary
End Function
%>
上面是我的微信token验证的asp代码,我测试了之后可以验证通过,说明代码没有问题。但是我换了另一个url,url里包含减号"-",就验证失败了。是验证token的url里不能含有"-"么?

url应该可以包含-的,应该是你url变了,那么token也应该会跟着变。
你需要重新根据url生成新的token。追问

token是自定义的吧,我只要代码里的token和配置里的token一致就可以了吧。还有就是,我上面的代码我进行了写文件的操作来检验获取的值,然而,在有-的那里,写文件操作没有执行

追答

因为URL变更,微信接口会有缓存。不会立即生效。
你如果是公共账户,可以取消关注,然后再重新关注。
没有生成txt,表明微信即可没访问你服务器。

温馨提示:答案为网友推荐,仅供参考
相似回答