2021-02-07-Enterprise WeChat api learning record (will be updated from time to time)

Pre-work

  • First of all, you have to ask your boss to assign the operation authority of the enterprise WeChat backend to you, so that you can log in to the enterprise WeChat and enter the official API document of the backend

Server-side API development

Basic concept introduction

Introduction to the basic concepts of official documents

  • You need to have some understanding of what the following terms represent in the official documentation
  • corpid
  • userid
  • agent
  • secret
  • access_token

Identity authentication (webpage authorization authentication)

New application

  • Log in to the company’s corporate WeChat backend first, and select an application in the application management to create your new menu
  • When creating a menu, you need to fill in a URL, which is the URL of your newly created menu link
  • This URL needs to provide you with the appid (enterprise id, the method to find above) and an accessible address of your project. This address is processed by urlencode (Baidu has an online tool)
  • After filling in this address, the establishment is complete

Get the identity of the currently logged in user

  • To obtain the identity of the currently logged in user, two parameters need to be passed to the official backend to obtain, code and access_token
  • code: When you click on the menu you created, when you jump to the address you wrote, a section will be added to the url, which is the value of the code, such as: &code=AAAAAAgG333qs9EdaPbCAP1VaOrjuNkiAZHTWgaWsZQ, so you only need Baidu how to get the url The above parameters can get the code

Obtain access_token (send a request to the following URL and it’s done)

  • Request method: GET (HTTPS)
    Request address: https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=ID&corpsecret=SECRET
    Note: The capitalized word ID and SECRET are marked here, which are variables that need to be replaced , Updated according to the actual obtained value. Other interfaces also use the same label, and will not be described again.
  • Corpid is the corporate id, corpsecret is the secret of the application you built

Send a request to get the userId of the currently logged in person

  • Request method: GET (HTTPS)
    Request address: https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE

  • Just fill in the value of access_token and code mentioned above.

  • The json returned by the request will have the value of userId

Send a request to get the complete information of the currently logged in person

  • Request method: GET (HTTPS)
    Request address: https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&userid=USERID
  • Just fill in access_token and userid

Guess you like

Origin blog.csdn.net/qq_41270550/article/details/113726560