The jsapi signature is sent to the jsapi signature.
Jsapi signature,
1. log on to the public platform and go to "function Settings" of "public account settings" and enter "JS interface security domain name ". This secure domain name does not need to be written to a specified page. It can be written to level 1 or level 2.
2. Introduce jsapi. There are two types of jsapi: http request and https
Http://res.wx.qq.com/open/js/jweixin-1.0.0.js -- http's
Https://res.wx.qq.com/open/js/jweixin-1.0.0.js -- it's https.
3. Write to js
This is an example. We can easily get the first three annotations, but the fourth signature is not very easy.
Wx. config ({debug: true, // enable the debugging mode. The returned values of all called APIs are displayed in the client alert. To view the input parameters, you can open them on the pc, the parameter information is output through log and printed only on the pc end. AppId: '', // required. The unique identifier timestamp:, // required. The timestamp of the generated signature is nonceStr:''. // required, sign the random string signature: '', // required. For details, see Appendix 1 jsApiList: [] // required. List of JS interfaces to be used, for a list of all JS interfaces, see Appendix 2 });
4. Let's take a look at the signature rules.
Signature Algorithm
The signature generation rules are as follows:
The fields involved in the signature include noncestr (random string), valid jsapi_ticket, timestamp (timestamp), and url (the URL of the current webpage, excluding # and its subsequent parts ). After all parameters to be signed are sorted in ascending order (lexicographically) according to the field name ASCII code, the format of the URL key-value pair is used (that is, key1 = value1 & key2 = value2 ...) Concatenate the string into string1. Note that all parameter names are lowercase characters. Perform sha1 encryption on string1, and use original values for field names and field values without URL escaping.
---------------- Jsapi_ticket
There is a jsapi_ticket here, which is very embarrassing. We need to make our own request. The Request Path is as follows:
String uri = string. Format (@ "https://api.weixin.qq.com/cgi-bin/ticket/getticket? Access_token = {0} & type = jsapi ",ReturnAccess_token ());
ReturnAccess_token (). This is the method for obtaining the TOKEN,
You can use this connection to Get the JSAPI_TICKET.
--------------- URL
In the signature, the URL is the page we are currently using.
The next step is to generate a signature. I use MVC to do this, so I will demonstrate it to everyone using MVC.
---------- Paste it directly to generate the signature code, but the code is too messy and straightforward. Please note that the signature should be used at last. I forgot to write it ....
This method returns a key-value pair. I save the key-Value Pair directly to ViewData and use it directly on the page. Then
OK is finished
If you feel better, please add my QQ Group
ASP. NET e 460845632