WeChat public platform development and learning series (3): webpage authorization for obtaining basic user information and basic public information

Source: Internet
Author: User

Public platform development and learning series (III): webpage authorization for obtaining basic user information and basic public information

Official documents: http://mp.weixin.qq.com/wiki/4/9ac2e7b1f1d22e9e57260f6553822520.html

In the interface permission table

Change it to the domain name of the server

According to the official documentation, an authorization Page Link is required, which can be implemented using the encapsulated OAuthApi. GetAuthorizeUrl () method.

1 menu. button. add (new MenuFull_RootButton () {key = "link", name = "link", type = ButtonType. view. toString (), 2 url = OAuthApi. getAuthorizeUrl (appId, "http://qxw1649420168.my3w.com/Home/GetUser", "123", OAuthScope. snsapi_userinfo) 3}); View Code

The callback link code is as follows:

1 public ActionResult GetUser (string code, string state) 2 {3 4 if (String. isNullOrEmpty (code) 5 {6 return Content ("unauthorized"); 7} 8 else 9 {10 OAuthAccessTokenResult result = OAuthApi. getAccessToken (appId, secret, code); 11 OAuthUserInfo userInfo = OAuthApi. getUserInfo (result. access_token, result. openid); 12 13 return Content (userInfo. nickname + "" + userInfo. openid); 14} 15} View Code

 

Related Article

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.