Skip to content

Commit

Permalink
网页授权获取用户信息
Browse files Browse the repository at this point in the history
  • Loading branch information
dedemao authored Oct 26, 2020
1 parent f2baf35 commit 2d91fb8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*/
header('Content-type:text/html; Charset=utf-8');
/*** 请填写以下配置信息 ***/
$scope = 'auth_base'; //auth_base或auth_userinfo。如果只需要获取用户id,填写auth_base即可。如需获取头像、昵称等信息,则填写auth_userinfo
$appid = ''; //https://open.alipay.com 账户中心->密钥管理->开放平台密钥,填写开通了“获取会员信息”应用的APPID
$scope = 'auth_user'; //auth_base或auth_user。如果只需要获取用户id,填写auth_base即可。如需获取头像、昵称等信息,则填写auth_user
$appid = 'xxxxx'; //https://open.alipay.com 账户中心->密钥管理->开放平台密钥,填写开通了“获取会员信息”应用的APPID
$signType = 'RSA2'; //签名算法类型,支持RSA2和RSA,推荐使用RSA2
//商户私钥,填写对应签名算法类型的私钥,如何生成密钥参考:https://docs.open.alipay.com/291/105971和https://docs.open.alipay.com/200/105310
$rsaPrivateKey='';
$rsaPrivateKey='xxxxx';
/*** 配置结束 ***/
$aliPay = new AlipayService();
$aliPay->setAppid($appid);
Expand All @@ -28,8 +28,8 @@
echo '<h1>'.$userinfo['error_response']['code'].':'.$userinfo['error_response']['sub_msg'].'</h1>';
exit();
}
if($userinfo['alipay_user_userinfo_share_response']){
$user = $userinfo['alipay_user_userinfo_share_response'];
if($userinfo['alipay_user_info_share_response']){
$user = $userinfo['alipay_user_info_share_response'];
//打印user信息
echo "<pre>";
print_r($user);die;
Expand Down Expand Up @@ -168,7 +168,7 @@ public function doGetUserInfo($token)
$commonConfigs = array(
//公共参数
'app_id' => $this->appId,
'method' => 'alipay.user.userinfo.share',//接口名称
'method' => 'alipay.user.info.share',//接口名称
'format' => 'JSON',
'charset'=>$this->charset,
'sign_type'=>'RSA2',
Expand Down

0 comments on commit 2d91fb8

Please sign in to comment.