How to micro-letter web developer to complete the signature verification

In doing micro-letter web development process, to use the interface JSD micro-channel, complete the signature efficacy job. But many people will encounter a variety of problems in the signing process, just the mentality of the explosion, it is up to how to properly complete the signature interface it?

First, log micro-channel public number backstage, set js security domain.

Second, the introduction of micro-channel js-sdk page.
The third step is to verify the configuration using the config interface injection permission.

Among the parameters, timestamp is a timestamp string that can be converted directly in the online search tool to convert a time into a timestamp, the current time is not necessarily to be, is only the last few days will do. nonceStr is a random string, you can fill in a random string, but the string after to make sure all the same. sinature is generated signature, how to generate this signature it?

The first acquisition access_token, jsapi_ticket.
First get access_token, and then get jsapi_ticket by access_token. Whether ccess_token or jsapi_ticket, have a survival period, which is about 7200 seconds, the survival period, it is best not get repeated, because it will cause confusion. You can use a database or file to get the ccess_token, jsapi_ticket preserved, then the provisions of the code re-acquired at a certain time of 7200 seconds, in order to avoid ccess_token, jsapi_ticket expired, get the best time is 5 minutes before the end of survival, but also 6900 or so seconds.

After obtaining the jsapi_ticket, that is, by signing request interface return signature. As for the interface which, you can find micro-channel development of the document, which is written in great detail. This interface required parameters are:

Several parameters need to compute the signature:
. 1, noncestr (random string), the distal end configuration is consistent with

2, effective jsapi_ticket,

3, timestamp (timestamp), with a front end configured with the same

4, url (the current page URL, without the # and later), pay attention to some of the characters in the url will be converted in some programs, resulting in url and page background url received inconsistent invalidate the signature.

After generating the signature at the distal end configuration, generally it.
My php website: kq.dbmkq.com

Guess you like

Origin blog.51cto.com/14632229/2456042