Question about using permission signature algorithm in javascript-WeChat JS-SDK

Source: Internet
Author: User
The signed string is {code...}. The url contains ", for example, urlmp.weixin.qq.com? Paramsvalue (no "") urlmp.weixin.qq.com? Paramsvalue (with "") will cause "invalidurldomain" error. Why? The signed string is:

jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg&noncestr=Wm3WZYTPz0wzccnW&timestamp=1414587457&url=http://mp.weixin.qq.com?params=value

The url contains "/", for example:
Url = http://mp.weixin.qq.com? Params = value (no "/")
Url = http://mp.weixin.qq.com /? Params = value (with "/")
This will cause the "invalid url domain" error. Why?

Reply content:

The signed string is:

jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg&noncestr=Wm3WZYTPz0wzccnW&timestamp=1414587457&url=http://mp.weixin.qq.com?params=value

The url contains "/", for example:
Url = http://mp.weixin.qq.com? Params = value (no "/")
Url = http://mp.weixin.qq.com /? Params = value (with "/")
This will cause the "invalid url domain" error. Why?

Is this a problem?

'/' Will lead to incomplete parameters in the url you pass. The url received by the sdk does not match your actual url. Of course, it will be invalid domain.

This is related to the method that your front-end submits the url to the interface. Simply put, the url encode can be avoided. Some libraries such as jQuery or Zepto may encapsulate the encode step in ajax. If you write native ajax, you may miss the encode, resulting in incomplete parameter transmission.

Related Article

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.