Current location - Quotes Website - Collection of slogans - How does java get openid of WeChat?
How does java get openid of WeChat?
1 first of all, we need to enter our service number, click on the developer center in the left column-> modify the authorized value of the webpage, and get the basic information of the user. Suppose our external ip is183.33.212.175, and the port number of tomcat is 80 16. The modification is183.33.212.438+06.

2 create WeiXinOauth2Token class. This class has the following properties: (add get, set methods yourself)

Private string accessToken

Private int expiresIn

Private string refeshToken

Private string openId

Private string range;

3 Call the authorization interface of WeChat

/connect/oauth2/authorize? Appid = appid & redirect uri&; Code & scope = snsapi _ base & state = state # wechat _ redirect.

4 and then encode redirect_uri.

5 get the user openid

/u 011160656/articles/details /4 18475 17