Home > Mobile >  WeChat JS - SDK from WeChat server to download images can sometimes download success, download is no
WeChat JS - SDK from WeChat server to download images can sometimes download success, download is no

Time:10-05

I am in this way to WeChat pull photos:
http://file.api.weixin.qq.com/cgi-bin/media/get? Access_token=? & Media_id=?
Pull back the first time:
{" errcode ": 40001," errmsg ":" invalid the credential, access_token is invalid or not latest hint: [_FXhNa0003vr60!] "}
The second time or return:
{" errcode ": 40001," errmsg ":" invalid the credential, access_token is invalid or not latest hint: [.. yq6a0501vr49!] "}
The third pull a success!
No law, is now 2 hours to get an access_token, if failure, access_token is impossible for the third time in the same access_token will pull a success, the problem for months, please solve!

CodePudding user response:

Come on silver, crazy!

CodePudding user response:

Who came to the rescue?

CodePudding user response:

His check whether token cache is a problem with the preservation and overdue verification cache has expired last time but not to get so for less than 2 hours and then got a new success
Every time you first remove the cache to get there is something wrong with the watch

CodePudding user response:

There are a few problems
First, not two hours to get a token, ought to according to WeChat returned timeout setting
Second, WeChat really has a problem, the same file download 10 times, random failure, you don't have to doubt the validity of your token, with the experience, we use every 200 + 200 * n ms, n is cycles., n is set to 10 times, basically can guarantee 99% file download successful. The rest of the still fail, let users retransmission
  • Related