本文整理匯總了PHP中HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth2ResourceOwner::getUserInformation方法的典型用法代碼示例。如果您正苦於以下問題:PHP GenericOAuth2ResourceOwner::getUserInformation方法的具體用法?PHP GenericOAuth2ResourceOwner::getUserInformation怎麽用?PHP GenericOAuth2ResourceOwner::getUserInformation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth2ResourceOwner
的用法示例。
在下文中一共展示了GenericOAuth2ResourceOwner::getUserInformation方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetUserInformation
public function testGetUserInformation()
{
$this->markTestSkipped('Test will work from PHPUnit 3.7 onwards. See: https://github.com/sebastianbergmann/phpunit-mock-objects/issues/47.');
$this->mockBuzz($this->userResponse);
$userResponse = $this->resourceOwner->getUserInformation('access_token');
$this->assertEquals('bar', $userResponse->getUsername());
$this->assertEquals('access_token', $userResponse->getAccessToken());
}
示例2: testGetUserInformationFailure
public function testGetUserInformationFailure()
{
$exception = new RequestException();
$this->buzzClient->expects($this->once())->method('send')->will($this->throwException($exception));
try {
$this->resourceOwner->getUserInformation(array('access_token' => 'token'));
$this->fail('An exception should have been raised');
} catch (HttpTransportException $e) {
$this->assertSame($exception, $e->getPrevious());
}
}
示例3: testGetUserInformation
public function testGetUserInformation()
{
$this->mockBuzz($this->userResponse, 'application/json; charset=utf-8');
/**
* @var $userResponse \HWI\Bundle\OAuthBundle\OAuth\Response\AbstractUserResponse
*/
$userResponse = $this->resourceOwner->getUserInformation(array('access_token' => 'token'));
$this->assertEquals('1', $userResponse->getUsername());
$this->assertEquals('bar', $userResponse->getNickname());
$this->assertEquals('token', $userResponse->getAccessToken());
$this->assertNull($userResponse->getRefreshToken());
$this->assertNull($userResponse->getExpiresIn());
}
示例4: getUserInformation
/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
if ($this->options['appsecret_proof']) {
$extraParameters['appsecret_proof'] = hash_hmac('sha256', $accessToken['access_token'], $this->options['client_secret']);
}
return parent::getUserInformation($accessToken, $extraParameters);
}
示例5: getUserInformation
/**
* Override for Orcid
*
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
if (!array_key_exists('orcid', $accessToken)) {
return parent::getUserInformation($accessToken, $extraParameters);
}
$orcidService = new OrcidService();
$bio = $orcidService->getBio($accessToken["orcid"]);
$response = $this->getUserResponse();
$response->setResponse($bio);
$response->setResourceOwner($this);
$response->setOAuthToken(new OAuthToken($accessToken));
return $response;
}
示例6: getUserInformation
/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
$response = parent::getUserInformation($accessToken, $extraParameters);
$responseData = $response->getResponse();
// fetch the email addresses linked to the account
if (empty($responseData['email'])) {
$content = $this->httpRequest($this->normalizeUrl($this->options['emails_url']), null, array('Authorization: Bearer ' . $accessToken['access_token']));
foreach ($this->getResponseContent($content)['values'] as $email) {
// we only need the primary email address
if (true === $email['is_primary']) {
$responseData['email'] = $email['email'];
}
}
$response->setResponse($responseData);
}
return $response;
}
示例7: getUserInformation
/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
// SalesForce returns the infos_url in the OAuth Response Token
$this->options['infos_url'] = $accessToken['id'];
return parent::getUserInformation($accessToken, $extraParameters);
}