//获取微信 客户端授权信息
function getWxinfo($url){
//获取token
$appid = C('wxconfig')['appid']; //appid
$secret = C('wxconfig')['secret'];//secret
$code = $_REQUEST;
if(!isset($code['code'])){
header("location:https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$url."&response_type=code&scope=snsapi_userinfo&state=123456#wechat_redirect");
exit;
}
$arr = file_get_contents("https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."&secret=".$secret."&code=".$code['code']."&grant_type=authorization_code");
$arr = json_decode($arr,true);
$userinfo = file_get_contents("https://api.weixin.qq.com/sns/userinfo?access_token=".$arr['access_token']."&openid=".$arr['openid']."&lang=zh_CN");
return $userinfo;
}
function getWxinfo($url){
//获取token
$appid = C('wxconfig')['appid']; //appid
$secret = C('wxconfig')['secret'];//secret
$code = $_REQUEST;
if(!isset($code['code'])){
header("location:https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$url."&response_type=code&scope=snsapi_userinfo&state=123456#wechat_redirect");
exit;
}
$arr = file_get_contents("https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."&secret=".$secret."&code=".$code['code']."&grant_type=authorization_code");
$arr = json_decode($arr,true);
$userinfo = file_get_contents("https://api.weixin.qq.com/sns/userinfo?access_token=".$arr['access_token']."&openid=".$arr['openid']."&lang=zh_CN");
return $userinfo;
}