Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn about the public platform. config: invalid signature has been the solution to this error.
If it is an invalid signature error. Check in the following order:
1. confirm that the signature algorithm is correct, available http://mp.weixin.qq.com/debug/cgi-bin/sandbox? T = jsapisign page tool for verification.
2. Check that the nonceStr in config (standard upper-case S in js) and timestamp are consistent with the corresponding noncestr and timestamp in the signature.
3. confirm that the url is the complete url of the page (please go to the current page alert (location. href. split ('#') [0]), including 'HTTP (s): // ', and '? 'Get parameter section, but does not include the section after '#' hash.
4. Check that the appid in config is consistent with the appid used to obtain jsapi_ticket.
5. Make sure that access_token and jsapi_ticket are cached.
This is the focus:
Make sure that you obtain the signed url dynamically. For details about the dynamic page, see the php implementation method in the instance code. If the html static page uploads the url to the background signature through ajax at the front end, the front end needs to use js to obtain the link for removing the '#' hash part of the current page (available location. href. split ('#') [0], and encodeURIComponent is required), because once the page is shared, the client adds other parameters to the end of your link. If it does not dynamically obtain the current link, the shared page signature will fail.
How to verify the correct method:
The dynamic url acquisition method is as follows:
$protocol = (!empty($_SERVER[HTTPS]) && $_SERVER[HTTPS] !== off || $_SERVER[SERVER_PORT] == 443) ? "https://" : "http://";
$url = $protocol.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];Steps:
First, go to the alert (location. href. split ('#') [0]) page.
Then you can print out whether the dynamically obtained url is the same as your alert url. Must be exactly the same, including case.
If you find the difference, you can change it as needed. It should be the same. The signature must be verified.
If you have any questions, I will reply to them one by one.
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB