以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- errMsg : config:invalid signature签名错误 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=120141) |
||||||||||||||||
-- 作者:fubblyc -- 发布时间:2018/6/8 0:07:00 -- errMsg : config:invalid signature签名错误 老师,我们生成的签名和微信提供的调试的签名不一样: |
||||||||||||||||
-- 作者:fubblyc -- 发布时间:2018/6/8 7:37:00 -- 昨天下午还可以,到了晚上不知道怎么回事就不行了 |
||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2018/6/8 8:40:00 -- 用的是哪个接口?ticket好像是只有2小时的时效,是不是过时了 |
||||||||||||||||
-- 作者:有点甜 -- 发布时间:2018/6/8 8:57:00 -- jsapi_ticket获取有问题,定时获取更新
获取api_ticketapi_ticket 是用于调用微信卡券JS API的临时票据,有效期为7200 秒,通过access_token 来获取。 开发者注意事项: 1.此用于卡券接口签名的api_ticket与步骤三中通过config接口注入权限验证配置使用的jsapi_ticket不同。 2.由于获取api_ticket 的api 调用次数非常有限,频繁刷新api_ticket 会导致api调用受限,影响自身业务,开发者需在自己的服务存储与更新api_ticket。 接口调用请求说明
参数说明
返回数据 数据示例:
|
||||||||||||||||
-- 作者:fubblyc -- 发布时间:2018/6/8 10:12:00 -- 甜老师,我是弄的扫一扫的SDK接口,不是卡券的。 我照着帮助的 扫一扫 做的
[此贴子已经被作者于2018/6/8 10:11:45编辑过]
|
||||||||||||||||
-- 作者:fubblyc -- 发布时间:2018/6/8 10:20:00 -- 代码如下: GetJsSignature: Dim gongsi As String = args(3) Dim dt As DataTable Dim dr As DataRow Dim cmd As new SQLCommand cmd.C cmd.CommandText = "selec t * from 账套配置 where 账套 = \'" & gongsi & "\'" dt = cmd.ExecuteReader(True) If dt.DataRows.Count > 0 Then dr = dt.DataRows(0) Dim TicketCreateTime As Date = dr("TicketCreateTime") \'记录最近一次生成access_token的时间 Dim Ticket As String Dim AppId As String= dr("AppId") Dim AppSecret As String = dr("AppSecret") Dim tp As TimeSpan = Date.Now - TicketCreateTime If tp.TotalSeconds > 3600 Then Dim url As String = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi" Dim hc As New HttpClient(CExp(url,Functions.Execute("GetAccessToken",gongsi))) Dim ret As String = hc.GetData() If ret = "" Then \'如果失败,再尝试一次 hc.GetData() End If dr("TicketCreateTime") = Date.Now() Dim jo As JObject = JObject.Parse(ret) If jo("errcode") = "0" Then dr("Ticket") = jo("ticket") Else PopMessage("获取jsapi_ticket,原因:" & vbcrlf & jo.ToString) End If dr.save() End If ticket = dr("Ticket") 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() End If 扫一扫网页代码: Dim e As RequestEventArgs = args(0) Dim cmd As new SQLCommand cmd.C cmd.CommandText = "selec t top 1 创建账套 from {gift} where ka_id = \'" & cardid & "\'" Dim dt As DataTable = cmd.ExecuteReader() Dim dr As DataRow If dt.DataRows.Count >= 1 Then dr = dt.DataRows(0) End If Dim gongsi As String = dr("创建账套") Dim wb As new WeUI wb.AppendHTML("<script src=\'http://res.wx.qq.com/open/js/jweixin-1.2.0.js\'></script>",True) \'引入JS-SDK库 wb.AppendHTML("<script src=\'./lib/jssdk2.js\'></script>") \'引入脚本文件 \'在页面注入权限验证配置 Dim st As New Date(1970,1,1,8,0,0) Dim appid As String = "wx993xxxxxc690" \'开发者ID Dim timestamp As Integer = CInt((Date.Now - st).TotalSeconds()) \'时间戳 Dim noncestr As String = Rand.NextString(16) \'随机字符 Dim url As String = e.Request.URL.ToString \'当前页面地址 Dim signature As String = Functions.Execute("GetJsSignature", noncestr, timestamp, url,gongsi) \'生成权限验证签名 PopMessage("signature:" & signature) Dim cfg As String = "wx.config({appId:\'{0}\',timestamp:{1},nonceStr:\'{2}\',signature:\'{3}\',jsApiList:[\'scanQRCode\']});" wb.AppendHTML("<script>" & CExp(cfg,appid,timestamp,noncestr,signature) & "</script>",True) \'开始正常生成网页内容 wb.AddPageTitle("","ph1","支付","XX公司") wb.AddForm("","form1","http://www.yijiansoft.net:94/koukuancl.htm") With wb.AddInputGroup("form1","ipg1","") With .AddInputCell("ic1") .AddLabel("lbh","小票单号",0) With .AddInput("xp","text",1) .Placeholder = "点右边扫小票条码" .Enabled = False End With .AddVcodeButton("scan","扫一扫",2) \'增加二维码扫描按钮,2表示显示在右边 End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "确定", "submit") End With e.WriteString(wb.Build) \'生成网页 [此贴子已经被作者于2018/6/8 10:24:09编辑过]
|
||||||||||||||||
-- 作者:有点甜 -- 发布时间:2018/6/8 10:29:00 -- 在函数 GetJsSignature 加入msgbox,弹出各个值看一下,看是否进入执行了 getticket 的代码。 |
||||||||||||||||
-- 作者:fubblyc -- 发布时间:2018/6/8 12:06:00 -- 甜老师,经测试,超过3600就有执行了。 If tp.TotalSeconds > 3600 Then Dim url As String = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi" Dim hc As New HttpClient(CExp(url,Functions.Execute("GetAccessToken",gongsi))) Dim ret As String = hc.GetData() If ret = "" Then \'如果失败,再尝试一次 hc.GetData() End If dr("TicketCreateTime") = Date.Now() Dim jo As JObject = JObject.Parse(ret) If jo("errcode") = "0" Then dr("Ticket") = jo("ticket") PopMessage("重新获取") Else PopMessage("获取jsapi_ticket,原因:" & vbcrlf & jo.ToString) End If dr.save() End If ticket = dr("Ticket") 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() [此贴子已经被作者于2018/6/8 12:09:55编辑过]
|
||||||||||||||||
-- 作者:fubblyc -- 发布时间:2018/6/8 12:12:00 -- 这是 FT 的例子 |
||||||||||||||||
-- 作者:有点甜 -- 发布时间:2018/6/8 12:17:00 -- 1、msgbox执行了这句代码了没?
dr("Ticket") = jo("ticket")
2、如果进入执行了 getticket 后生成的签名是否正确?
3、如果还是有问题,就是你 AppId、AppSecret 等值不对应导致的。
Dim appid As String = "wx993xxxxxc690" \'开发者ID |