Obtaining micro-channel authorization code / openid

Micro-letter web page authorization

If a user visits a third-party web page in the micro-client letter, the public numbers can, to get basic user information through micro-letter web authorization mechanisms, so as to realize the business logic.

Instructions on the page callback authorized domain name

1, before the micro-channel public number requesting user web authorization, developers need to first come first public platform for the official website of "Development - Interface Permissions - Web Services - Web Account - Web authorization to obtain information about users' configuration options, modify the authorization callback domain . Please note that the domain name is filled in here (a string), instead of URL, so do not add http: // and other protocol header; 

2, authorize callback domain configuration specification for the whole domain name, such as web authorization required domain name: www.qq.com, after configuring this domain name following page http://www.qq.com/music.html, http: // www.qq.com/login.html can be OAuth2.0 authentication. But http://pay.qq.com, http://music.qq.com, http://qq.com can not be authenticated OAuth2.0 

3, if the public number to log licensed to third-party developers to manage, you do not have to do any settings, can be achieved by a third party authorized page number instead of the public.

Check the micro-channel authorization web service.

Page account    pages authorized to obtain information about users      unlimited modifications       

Click Edit, go to http://www.xxxx.cn changed www.xxxx.cn will not appear redirect_uri parameter error!

Note: http: //www.xxxx.cn this page is authorized by safety monitoring, we do not know if this is a problem, then when the program calling discovery redirect_uri parameter error, view the document, came back to find the original is here mistake.

// Get the user's OpenID
  function getBaseInfo () {
   .. 1 // acquired code
   $ appid = "qq1813284q1q6q8888"; // here appid presentation using a fake
   $ redirect_uri = urlencode ( "http://www.xxxx.cn /xxx.php/Index/getUserOpenId");// here need to address HTTP: //
   $ url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" $ AppID.. "the redirect_uri = &" $ the redirect_uri "code = & response_type snsapi_base & scope = & # 123 wechat_redirect State =";..
   header ( 'LOCATION:'. $ URL);
  }

  getUserOpenId function () {
   . // 2 to obtain authorization page of the access_token
   $ appid = "qq1813284q1q6q8888"; // here appid false presentation using
   $ appsecret = "61qqqq36745987167q73bq1q2552qq75"; // here appsecret false presentation using
   $ = $ _ the GET code [ 'code'];
   .... $ URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" $ AppID "Secret = &" $ appsecret "code = & . ". $ code" & grant_type = authorization_code ";
   // user pulling. 3 OpenID.
   $ RES = $ this-> http_curl ($ URL, 'GET');

 var_dump ($ res); // print to see the user's openid

}

Guess you like

Origin www.cnblogs.com/eeds-wangwei/p/11993197.html