本文整理汇总了PHP中HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface::getExpiresIn方法的典型用法代码示例。如果您正苦于以下问题:PHP UserResponseInterface::getExpiresIn方法的具体用法?PHP UserResponseInterface::getExpiresIn怎么用?PHP UserResponseInterface::getExpiresIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface
的用法示例。
在下文中一共展示了UserResponseInterface::getExpiresIn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadUserByOAuthUserResponse
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$user = $this->userRepository->findOneBy(['spotifyId' => $response->getUsername()]);
if (!$user instanceof SpotifyUser) {
$user = new SpotifyUser($response->getUsername());
}
$user->setSpotifyId($response->getUsername())->setDisplayName($response->getRealName())->setAccessToken($response->getAccessToken())->setAccessTokenExpires(time() + $response->getExpiresIn())->setRefreshToken($response->getRefreshToken())->setProfileUrl($response->getResponse()['href']);
$responseHasImages = isset($response->getResponse()['images']) && is_array($response->getResponse()['images']);
$responseImageExists = array_key_exists('url', $response->getResponse()['images'][0]);
if ($responseHasImages && $responseImageExists) {
$user->setImageUrl($response->getResponse()['images'][0]['url']);
}
$this->em->persist($user);
$this->em->flush();
return $this->loadUserByUsername($user->getUsername());
}
示例2: updateAuthorization
/**
* Updates an existing authorization with data from the resource owner
*
* @param Authorization $authorization Authorization
* @param UserResponseInterface $response Response of the resource owner
*
* @return Authorization
*/
protected function updateAuthorization(Authorization $authorization, UserResponseInterface $response)
{
$expirationDate = $this->getExpirationDate($response->getExpiresIn());
$authorization->setAuthorizationToken($response->getAccessToken())->setExpirationDate($expirationDate);
return $authorization;
}