PayPal\Auth\Openid\PPOpenIdUserinfo::getUserinfo PHP Method

getUserinfo() public static method

returns user details
public static getUserinfo ( array $params, PPApiContext $apiContext = null ) : PPOpenIdUserinfo
$params array (allowed values are access_token) access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls
$apiContext PayPal\Common\PPApiContext Optional API Context
return PPOpenIdUserinfo
    public static function getUserinfo($params, $apiContext = null)
    {
        static $allowedParams = array('schema' => 1);
        if (is_null($apiContext)) {
            $apiContext = new PPApiContext();
        }
        if (!array_key_exists('schema', $params)) {
            $params['schema'] = 'openid';
        }
        $requestUrl = "/v1/identity/openidconnect/userinfo?" . http_build_query(array_intersect_key($params, $allowedParams));
        $call = new PPRestCall($apiContext);
        $ret = new PPOpenIdUserinfo();
        $ret->fromJson($call->execute(array(new PPOpenIdHandler($apiContext)), $requestUrl, "GET", "", array('Authorization' => "Bearer " . $params['access_token'], 'Content-Type' => 'x-www-form-urlencoded')));
        return $ret;
    }

Usage Example

コード例 #1
0
 /**
  * @test
  */
 public function testInvalidParamUserInfoCall()
 {
     $this->setExpectedException('PayPal\\Exception\\PPConnectionException');
     PPOpenIdUserinfo::getUserinfo(array('access_token' => 'accessToken'));
 }