JavaScript-WeChat interface calls have been invalid signature

Source: Internet
Author: User

The shared interface was recently used in the development process, but the invalid signature was always present when the signature was generated according to his document.
According to the testing tools he provided, the results were correct.

The way I get the signature here is to get it in a static page by asynchronously passing the current URL to PHP, as follows:

The PHP Get method uses the official provided example to modify, the signature algorithm should be no problem.
The URL acquisition method is a reference to http://segmentfault.com/q/1010000002502269, which is implemented.
Does anyone know what the problem is?
PS: Just test found that the direct access to the page www.8-yi.com/passby/on the phone, and then can be shared normally, that is, the signature is correct, but after sharing (sharing the settings link is: www.8-yi.com/passby/), If you open it again, the signature is invalid, and alert finds that the URL is appended with some parameters, but even so, the URL is not a mistake? Why is the signature that is calculated to be invalid?
Because my URL itself doesn't require parameters, I changed the URL acquisition method to:
var targeturl = Location.href.split ('?') [0];//here with?] Get the URL as a split
This gets the URL is the same as the direct access, but the signature is still invalid!!
It's going crazy.
Thank you, everyone.

Reply content:

The shared interface was recently used in the development process, but the invalid signature was always present when the signature was generated according to his document.
According to the testing tools he provided, the results were correct.

The way I get the signature here is to get it in a static page by asynchronously passing the current URL to PHP, as follows:

The PHP Get method uses the official provided example to modify, the signature algorithm should be no problem.
The URL acquisition method is a reference to http://segmentfault.com/q/1010000002502269, which is implemented.
Does anyone know what the problem is?
PS: Just test found that the direct access to the page www.8-yi.com/passby/on the phone, and then can be shared normally, that is, the signature is correct, but after sharing (sharing the settings link is: www.8-yi.com/passby/), If you open it again, the signature is invalid, and alert finds that the URL is appended with some parameters, but even so, the URL is not a mistake? Why is the signature that is calculated to be invalid?
Because my URL itself doesn't require parameters, I changed the URL acquisition method to:
var targeturl = Location.href.split ('?') [0];//here with?] Get the URL as a split
This gets the URL is the same as the direct access, but the signature is still invalid!!
It's going crazy.
Thank you, everyone.

Haha, I found the problem, here to share with you.
My question was that the signature would not be valid for two sharing, because two shared connections were added to the parameters, two (or more) so that the two shared URLs became www.8-yi.com/passby/index.html?from=singlemessage &Isappinstalled=0
Note that the & symbol here, because I am using the Get method, so that the server receives the URL will be lost & Subsequent characters, so the URL is incorrect, resulting in invalid signature.
The workaround is also simple, which is to convert the character to encode before passing the parameter, like this:
var targeturl = location.href.split (' # ') [0];
TargetUrl = Targeturl.replace (' & ', '%26 ');
You can do it.

The collection has studied .....

If entered on the report invalid signature error How to solve, with the official JSSDK and sample files, the test number AppID and Appsecret

The address cannot be www.sxsxsx/aad/.

Be sure to write the address complete, index.php, or there will be problems, and it is difficult to find this fatal error

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.