Introduction to WeChat enterprise account development for obtaining user information

Source: Internet
Author: User
This article analyzes the introduction of enterprise ID development to get user information. when a user clicks an application and jumps to the URL we set, it does not actually contain any user information. in order to get user information, we need to use the provided OAuth2.0 interface.

To obtain user information, follow these steps:

  1. Construct a URL to obtain the code

  2. Obtain member information by code

1. construct a URL to obtain the code

If an enterprise requires employees to carry their identity information when they jump to the Enterprise webpage, the following link must be constructed:

Https://open.weixin.qq.com/connect/oauth2/authorize? Appid = CORPID & redirect_uri = REDIRECT_URI & response_type = code & scope = SCOPE & state = STATE # wechat_redirect

Parameter description

Parameters Required Description
Appid Yes Enterprise CorpID
Redirect_uri Yes URL of the redirection callback link after Authorization. use urlencode to process the link.
Response_type Yes Return type, which is fixed as: code
Scope Yes Application authorization scope, which is fixed as: snsapi_base
State No With the state parameter, the enterprise can enter the a-zA-Z0-9 parameter value, length cannot exceed 128 bytes
# Wechat_redirect Yes The terminal uses this parameter to determine whether identity information is required.

After the employee clicks, the page will jump to redirect_uri? Code = CODE & state = STATE. enterprises can obtain the employee's userid based on the code parameter.

Appid

Obtain as shown in

2. obtain member information based on code

Obtain member information by code
  • Request description

Https request method: GET

Https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo? Access_token = ACCESS_TOKEN & code = CODE

  • Parameter description

Parameters Required Description
Access_token Yes Interface call credential
Code Yes The code obtained through member authorization will vary with the code carried by each member authorization. the code can only be used once and will automatically expire if it is not used for 10 minutes.
  • Permission Description

The domain name to be redirected must match the trusted domain name of any application in the management group.

  • Returned results

A) An example is returned when an enterprise member is authorized:

    {       "UserId":"USERID",       "DeviceId":"DEVICEID"    }

The above is the detailed introduction of enterprise code development to get user information. For more information, see other related articles on php Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.