码迷,mamicode.com
首页 > 微信 > 详细

php使用微信登录

时间:2019-12-21 11:38:16      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:response   nbsp   code   pps   grant   pid   微信   http   ken   

1.第一步

$hosturl = urlencode(‘‘);//异步回调地址
$wechatInfo = WechatInfo::get_wechat(); //查询appid
$url    = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$wechatInfo[‘appid‘]}&redirect_uri={$hosturl}&response_type=code&scope=snsapi_base&state={$user[‘user_id‘]}#wechat_redirect";
$result = [‘status‘ => 2, ‘msg‘ => ‘登陆成功‘, ‘data‘ => $user, ‘url‘ => $url];

2.异步回调地址

$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);

 

 

有那些不明白的,可以在评论里留言,我会及时的回复大家的

php使用微信登录

标签:response   nbsp   code   pps   grant   pid   微信   http   ken   

原文地址:https://www.cnblogs.com/shineguang/p/12076254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!