以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 微信服务端报获取jsapi_ticket,原因: 报错要怎么处理? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=139294) |
-- 作者:ycwk -- 发布时间:2019/8/10 9:52:00 -- 微信服务端报获取jsapi_ticket,原因: 报错要怎么处理? ![]() ![]() 看样子好像是token过期了,可是怎么防止这种报错呢?
[此贴子已经被作者于2019/8/10 9:53:45编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/8/10 10:05:00 -- 监测超时时间,保证token是最新的:http://www.foxtable.com/mobilehelp/topics/0178.htm 另外,1楼的报错是自己弹出来的,可以自己解析json分析错误原因:http://www.foxtable.com/mobilehelp/topics/0140.htm,然后做对应的处理
|
-- 作者:ycwk -- 发布时间:2019/8/10 10:39:00 -- 全部用的官方例子的 自定义函数 Getaccesstoken,我看代码里也是每一个小时刷新一次,但就不知道这个accesstoken过期是怎么来的 Static CreateTime As Date \'记录最近一次生成access_token的时间 Static AccessTocken As String \'记录最近一次生成的access_token Dim AppId As String= "wx75369a" \'开发者ID Dim AppSecret As String = "6fecdca78c5e" \'开发者密匙 Dim tp As TimeSpan = Date.Now - CreateTime Dim url As String = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}" If tp.TotalSeconds > 3600 Then Dim hc As New HttpClient(CExp(url,AppId,AppSecret)) 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") Is Nothing Then AccessTocken = jo("access_token") Else MessageBox.show("获取access_token失败,原因:" & vbcrlf & jo("errmsg").ToString) End If End If output.Show(AccessTocken)
|
-- 作者:有点蓝 -- 发布时间:2019/8/10 10:43:00 -- 参考:https://mp.weixin.qq.com/wiki?action=doc&id=mp1421140183&t=0.35531066460550753 公众号的accesstoken是排他性的,所以需要:http://www.foxtable.com/mobilehelp/topics/0233.htm
|
-- 作者:ycwk -- 发布时间:2019/8/10 10:52:00 -- 上午第二次报这个错误了,不知如何查起: 获取jsapi_ticket,原因: { "errcode": 40001, "errmsg": "invalid credential, access_token is invalid or not latest hint: [Tt2kaA03388879!]" } |
-- 作者:ycwk -- 发布时间:2019/8/10 11:07:00 -- 知道是排它的,特别去看了下有access_token的代码 和accesstoken 处的代码,都是调用的自定义函数获取的token ,除了授权页面处http://www.foxtable.com/mobilehelp/scr/0235.htm 网址中带有access_token这个应该不会有影响吧 |
-- 作者:ycwk -- 发布时间:2019/8/10 11:08:00 -- 问题是我不知道从哪儿弹出来的json啊,我去哪加代码解析呢? 感觉很随机,我自己测试根本出不来。 [此贴子已经被作者于2019/8/10 11:08:05编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/8/10 11:25:00 -- 参考:http://www.foxtable.com/mobilehelp/topics/0247.htm 看看还有没有其它客户端也调用微信接口。另外会不会即在本机测试,又在服务器测试
|