This article mainly introduces the example code of WeChat exercise step counting in the WeChat applet. The editor thinks it is quite good, so I will share it with you now and give it as a reference. Let’s follow the editor and take a look.
Nowadays, sports step counting is very popular, whether it is Ant Forest or WeChat. This article introduces the example code of WeChat small program WeChat sports step counting and shares it with everyone.
WeChat Mini Program API-WeChat Sports
Idea: The code obtained by wx.login requests the session_key obtained, the iv and encryptData obtained by wx.getWeRunData, and they are sent together to the background for decryption. .
Security concerns, because it is just an example, the session_key is passed directly. For security, it is best to encrypt it as shown in the figure below, store it in Redis, and then pass the key.
Small terminal code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
The background uses the official PHP version Demo: first process the login request , login.php directly returns session_key, and then requests decrypt.php together for decryption.
login.php part code
1 2 3 4 5 6 7 8 |
|
decrypt.php part code
1 2 3 4 5 6 7 8 |
|
The above is the detailed content of An example of how WeChat applet can obtain WeChat exercise steps (picture). For more information, please follow other related articles on the PHP Chinese website!