I use PHP to get user information from the PayPal authentication API, but unfortunately I only get user_id. I need email and payer_id in response. I read the documentation according to which I should receive several parameters in response, but I only get user_id. I have included all applications in application permissions. here is the getuserinfo documentation .
here is my code to get user information (I pass $ access_token to this function). I use credentials for the sandbox.
$api_url = 'https://api.sandbox.paypal.com/v1/oauth2/token/userinfo?schema=openid';
$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);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($http_code == 200)
return $data;
else if($http_code == 404)
return false;
else
return false;
my answer:
array:1 [▼ "user_id" => "https://www.paypal.com/webapps/auth/identity/user/HdoaS1nMgR_Ltt5mBTv4mRvC9P1wUrWt2NlOVH2e_3w"]
source
share