Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
2、新增一个自定义函数,函数名为"GetJsSignature",用于生成JS-SDK的授权签名,代码为:
Static
CreateTime
As
Date
'记录最近一次生成Ticket
的时间
Static
Ticket
As
String
'记录最近一次生成的Ticket
Dim tp As TimeSpan = Date.Now -
CreateTime
Dim ul As
String = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi"
If tp.TotalSeconds > 3600
Then
Dim hc As New HttpClient(CExp(ul,Functions.Execute("GetAccessToken")))
Dim ret As
String = hc.GetData()
If
ret = ""
Then
'如果失败,再尝试一次
hc.GetData()
End
If
CreateTime = Date.Now()
Dim
jo As JObject = JObject.Parse(ret)
If jo("errcode") = "0"
Then
Ticket = jo("ticket")
Else
MessageBox.show("获取jsapi_ticket,原因:"
& vbcrlf
& jo.ToString)
End
If
End
If
Dim signature As
String = CExp("jsapi_ticket={0}&noncestr={1}×tamp={2}&url={3}",Ticket,args(0),args(1),args(2))
Return Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signature, "SHA1").ToLower()
当域名访问用非80端口时就会出现40093的签名错误,请问加了其他端口要怎么处理才不出错
谢谢!