Paypal GetUserinfo(Identity)仅返回user_id

时间:2018-04-03 06:23:32

标签: paypal paypal-sandbox paypal-rest-sdk

我使用PHP从paypal身份API获取用户信息,但不幸的是我只收到user_id作为回应。我需要电子邮件和payer_id作为回应。我已经阅读了文档,根据我应该收到多个参数作为响应,但我只收到user_id。我已启用App权限中的所有范围。这是文档getuserinfo

这是获取用户信息的代码(我将$ access_token传递给此函数)。我正在使用沙盒凭证。

$api_url = 'https://api.sandbox.paypal.com/v1/oauth2/token/userinfo?schema=openid';//sandbox
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer '. $access_token, 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = json_decode(curl_exec($ch), true);
//dd($data);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($http_code == 200)
return $data;
else if($http_code == 404)
return false;
else
return false;

我的回复:

array:1 [▼  "user_id" => "https://www.paypal.com/webapps/auth/identity/user/HdoaS1nMgR_Ltt5mBTv4mRvC9P1wUrWt2NlOVH2e_3w"]

1 个答案:

答案 0 :(得分:0)

这很可能是您的问题:“返回的属性取决于为REST应用程序配置的范围”

https://developer.paypal.com/docs/integration/paypal-here/sandbox-testing/configuring-accounts/#create-a-rest-application

使用PayPal登录。启用“使用PayPal登录”时,单击“高级选项”,然后选择“默认情况下禁用的个人信息和地址信息”。