问一下,那个卡券本身是不是有什么要求,我现在是用公众号appid和secret获取的token和ticket,校验也是一样的,但也是报签名错误 String url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token="+accessToken+"&type="wx_card"&offset_type=1"; 获取ticket这个没错吧
wx.addCard 签名错误,请求帮助- 当前 Bug 的表现(可附上截图) 1、服务器端签名代码: [代码] var[代码] [代码]token = ws.GetAccessToken(Appid, Secret);[代码] [代码] [代码][代码]var[代码] [代码]timestamp = DateTime.Now.Ticks.ToString().Substring(0, 10);[代码] [代码] [代码][代码]var[代码] [代码]jsapi_ticket = Main.GetTicket(token);[代码] [代码] [代码][代码]string[代码] [代码]nonce_str = [代码][代码]"1000"[代码][代码];[代码] [代码] [代码][代码]string[代码] [代码]carid = [代码][代码]"p1SK9wg2SA3-0JFqzlddT6w53Gnc"[代码][代码];[代码] [代码] [代码][代码]string[代码] [代码]order = timestamp + jsapi_ticket + carid + nonce_str;[代码] [代码] [代码][代码]string[代码] [代码]signature = Main.MakeSha1Sign(order);[代码] [代码] [代码][代码]ret = ret.Replace([代码][代码]"{0}"[代码][代码], carid);[代码] [代码] [代码][代码]ret = ret.Replace([代码][代码]"{1}"[代码][代码], nonce_str);[代码] [代码] [代码][代码]ret = ret.Replace([代码][代码]"{2}"[代码][代码], timestamp);[代码] [代码] [代码][代码]ret = ret.Replace([代码][代码]"{3}"[代码][代码], jsapi_ticket);[代码] [代码] [代码][代码]ret = ret.Replace([代码][代码]"{4}"[代码][代码], signature);[代码] [代码] [代码][代码]HttpContext.Current.Response.Write(ret);[代码] 通过官方的签名校验工具,顺利通过 http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=cardsign 2、微信前端代码如下: [代码]{[代码][代码] [代码][代码]var[代码] [代码]timestamp = [代码][代码]""[代码][代码] [代码][代码]var[代码] [代码]signature = [代码][代码]""[代码][代码] [代码][代码]var[代码] [代码]cardid = [代码][代码]""[代码][代码] [代码][代码]var[代码] [代码]nonce_str[代码] [代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: app.globalData.host + [代码][代码]'/action/Handler.ashx?a=ticket&sid='[代码] [代码]+ app.globalData.shopid,[代码][代码] [代码][代码]header: {[代码][代码] [代码][代码]'content-type'[代码][代码]: [代码][代码]'application/json'[代码][代码], [代码][代码]// 默认值[代码][代码] [代码][代码]"X-SQL-AppKey"[代码][代码]: app.globalData.APPkey[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]if[代码] [代码](res.data) {[代码][代码] [代码][代码]console.log(res.data)[代码] [代码] [代码][代码]cardid = res.data.carid[代码] [代码] [代码][代码]var[代码] [代码]cardExt={}[代码][代码] [代码][代码]cardExt.timestamp = res.data.timestamp[代码][代码] [代码][代码]cardExt.signature = res.data.signature[代码][代码] [代码][代码]cardExt.nonceStr = res.data.nonce_str[代码] [代码] [代码][代码]wx.addCard({[代码][代码] [代码][代码]cardList: [{[代码][代码] [代码][代码]cardId: res.data.carid,[代码][代码] [代码][代码]cardExt: JSON.stringify(cardExt)[代码][代码] [代码][代码]}, ],[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log(res.cardList) [代码][代码]// 卡券添加结果[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]}[代码] 服务器端值正常接收,现在打开提示:签名错误! 服务器端返回代码: [代码]{carid: [代码][代码]"p1SK9wg2SA3-0JFqzlddT6w53Gnc"[代码][代码], nonce_str: [代码][代码]"wxapp"[代码][代码], timestamp: [代码][代码]"6369869659"[代码][代码], ticket: [代码][代码]"IpK_1T69hDhZkLQTlwsAX2aXDM0lanFPJGw_1HYYb1bNF-NF70JbgTlOoJahIro2-ifNz4bHRR-8kdH2O4SuYQ"[代码][代码], signature: [代码][代码]"04f21bd32a7a6d95a504fc066eeb928377a6e564"[代码][代码]}[代码] cardExt: JSON.stringify(cardExt) 输出值是这个: [代码]{[代码][代码]"timestamp"[代码][代码]:[代码][代码]"6369869659"[代码][代码],[代码][代码]"signature"[代码][代码]:[代码][代码]"04f21bd32a7a6d95a504fc066eeb928377a6e564"[代码][代码],[代码][代码]"nonceStr"[代码][代码]:[代码][代码]"wxapp"[代码][代码]}[代码] 小程序已经和公众号做了关联处理! 不知道哪里出问了问题,请求帮助,谢谢!
2019-12-07