WeChat share link appears config: invalid signature error solution

When developing WeChat needs to do a specific page to share, according to the officially provided jssdk.php file created by the signature packet debugging, everyone encountered the most The error and the most troublesome solution is probably the signature error, as shown below:

微信分享链接出现config:invalid signature错误的解决方法

Shared when prompted error "{"errMsg":"config:invalid signature"}"

Generally this error is mostly signed Failure, and the reasons for the failure of signature acquisition, all kinds of various, Yudou also encountered this situation during development, searched a lot of online tutorials, solved their own problems. Next, Yudou will organize these solutions in a unified way, I hope you can help everyone:

1, APPID and APPSECRET fill in the wrong

This error can go to the official debugging page to get access_token to see if it is correct Click to get access_token

According to the returned results, you can judge whether there is any error in APPID and APPSECRET in the page. If there is no error, you can click to get jsapi_ticket

to use the access_token obtained in the previous way to obtain jsapi_ticket by using http GET. If something goes wrong, it will return the corresponding description.

2, exceeds the daily access_token to get the upper limit

officially limited to 2000 requests per day, so if there is no cache access_token, it is easier to exceed the limit.

3, check if the status of WeChat public number is not normal

If the verification expires, it will be banned.

4, confirm the hump standard uppercase S in nonceStr

js in config, timestamp is consistent with the corresponding noncestr, timestamp used in the signature.

5, confirm that the url is the full url of the page

Please confirm on the current page alert(location.href.split('#')[0]), including the 'http(s)://' section ,as well as'? 'The GET parameter part later, but does not include the part after '#'hash, here in the article "Static page implementation WeChat sharing with thumbnails, title and description" has been explained at the end, you can modify it yourself.

6, configure curl to use ssl with certificate (https protocol) access switch

find the official jssdk.php, find the code:

  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true); 

will change true to false, because generally we are not Install the certificate (https protocol), so change true to false. Otherwise, if the site has a certificate installed, change false to true.

7, add the IP address of the server where the website is located to the whitelist

微信分享链接出现config:invalid signature错误的解决方法

8, reverse proxy problem

If the above check does not solve the problem, then check if your server is not set up. , nginx configuration reverse proxy code:

proxy_set_header Host $http_host;

后记:WeChat public account official did not give a detailed troubleshooting method for the signature error, everyone in the process of development will inevitably have various problems leading to signature errors, if above The method still does not solve your problem, you can leave a message below, everyone can communicate and solve!