Login using php micro letter

1. The first step

hosturl $ = urlencode ( ''); // asynchronous callback address 
$ wechatInfo = WechatInfo :: // query AppID; get_wechat ()
 $ url     https://open.weixin.qq.com/connect/oauth2/authorize = "? AppID = { $ wechatInfo [ 'AppID']} & the redirect_uri = { $ hosturl } & response_type = code & scope = snsapi_base & State = { $ User [ 'user_id']} # wechat_redirect " ;
 $ Result = [ 'Status' => 2, 'MSG' => 'login success', 'Data' => $ User , 'URL' => $ URL ];

2. asynchronous callback address

$code = input('code');
$user_id = input('state');
$wechatInfo = WechatInfo::get_wechat();
$appid  = $wechatInfo['appid'];
$secret = $wechatInfo['appsecret'];
$url    = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$secret}&code={$code}&grant_type=authorization_code";
$sdk =Jssdk::curlGet($url);

 

 

There are those who do not understand, you can leave a message in the comments, I will reply you timely of

Guess you like

Origin www.cnblogs.com/shineguang/p/12076254.html