Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure Wechat JSSDK

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to configure Wechat JSSDK, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

JSSDK use step 1: bind a domain name

Log in to the Wechat public platform and enter the "function Settings" of "official account Settings" to fill in "JS API Security Domain name".

Note: after logging in, you can view the corresponding API permissions in the developer Center.

Step 2: introduce the JS file

Introduce the following JS file (https is supported) on the page that needs to call the JS API: http://res.wx.qq.com/open/js/jweixin-1.6.0.js

If you need to further improve the stability of the service, when the above resources are not accessible, you can visit http://res2.wx.qq.com/open/js/jweixin-1.6.0.js (https is supported).

Note: AMD/CMD standard module loading method is supported.

Step 3: verify the configuration by injecting permissions through the config interface

All pages that need to use JS-SDK must first inject configuration information, otherwise they cannot be called (the same url only needs to be called once. The web app of the SPA that changes the url can be called each time the url changes. Currently, the Android Wechat client does not support the new H5 feature of pushState, so using pushState to implement web app pages will cause signature failure, which will be fixed in Android6.2).

Wx.config ({debug: true, / / enables debug mode. The returned values of all api called will be displayed in the alert on the client side. To view the parameters passed, you can open them on the PC side, and the parameter information will be typed out through log and printed only on the PC side. AppId:'', / / required, unique ID of official account timestamp:, / / required, timestamp for generating signature nonceStr:', / / required, random string for generating signature signature:', / / required, signature jsApiList: [] / / required, list of JS interfaces to be used}) Step 4: successfully verify the wx.ready through the ready API processing (function () {/ / config information verification will execute the ready method. All API calls must be performed after the config API obtains the result. Config is an asynchronous operation on the client side, so if you need to call the relevant API when the page is loaded, you must call the relevant API in the ready function to ensure correct execution. Interfaces that are called only when triggered by the user can be called directly and do not need to be placed in the ready function. Step 5: verify the failure of wx.error through the error API (function (res) {/ / config information verification failure will execute the error function. If the signature expires and the verification fails, the specific error information can be viewed in the debug mode of config or in the returned res parameter. For SPA, you can update the signature here. }). Thank you for reading this article carefully. I hope the article "how to configure Wechat JSSDK" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report