How to simulate the WeChat applet request code

The official document has written about obtaining the code of the applet
and calling the interface to obtain the login credential (code). Use the credentials to exchange for user login status information, including the user's unique identifier (openid) in the current Mini Program, the unique identifier under the WeChat Open Platform account (unionid, if the current Mini Program has been bound to the WeChat Open Platform account) and this login The session key (session_key), etc. The encryption and decryption communication of user data needs to be completed by relying on the session key.
It can be seen that the code of the applet is returned after authorization and is not generated locally, so you must log in to obtain the ones that cannot be simulated

Official sample code

wx.login({
  success (res) {
    if (res.code) {
      //发起网络请求
      wx.request({
        url: 'https://example.com/onLogin',
        data: {
          code: res.code
        }
      })
    } else {
      console.log('登录失败!' + res.errMsg)
    }
  }
})

At present, the small program code acquisition based on the PC terminal has been completed

Guess you like

Origin blog.csdn.net/qq_2974520784/article/details/128678104