本文整理汇总了PHP中BaseFacebook::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseFacebook::getUser方法的具体用法?PHP BaseFacebook::getUser怎么用?PHP BaseFacebook::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseFacebook
的用法示例。
在下文中一共展示了BaseFacebook::getUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
public function authenticate(TokenInterface $token)
{
if (!$this->supports($token)) {
return null;
}
$user = $token->getUser();
if ($user instanceof UserInterface) {
$this->userChecker->checkPostAuth($user);
$newToken = new FacebookUserToken($this->providerKey, $user, $user->getRoles());
$newToken->setAttributes($token->getAttributes());
return $newToken;
}
try {
if ($uid = $this->facebook->getUser()) {
$newToken = $this->createAuthenticatedToken($uid);
$newToken->setAttributes($token->getAttributes());
return $newToken;
}
} catch (AuthenticationException $failed) {
throw $failed;
} catch (\Exception $failed) {
throw new AuthenticationException($failed->getMessage(), null, (int) $failed->getCode(), $failed);
}
throw new AuthenticationException('The Facebook user could not be retrieved from the session.');
}
示例2: authenticate
public function authenticate(TokenInterface $token)
{
if (!$this->supports($token)) {
return null;
}
try {
if ($uid = $this->facebook->getUser()) {
$token->setUser($uid);
return $this->createAuthenticatedToken($uid);
}
} catch (AuthenticationException $failed) {
throw $failed;
} catch (\Exception $failed) {
throw new AuthenticationException('Unknown error', $failed->getMessage(), $failed->getCode(), $failed);
}
throw new AuthenticationException('The Facebook user could not be retrieved from the session.');
}
示例3: authenticate
public function authenticate(TokenInterface $token)
{
if (!$this->supports($token)) {
return null;
}
$user = $token->getUser();
if ($user instanceof UserInterface) {
$this->userChecker->checkPostAuth($user);
$newToken = new FacebookUserToken($this->providerKey, $user, $user->getRoles(), $token->getAccessToken());
$newToken->setAttributes($token->getAttributes());
return $newToken;
}
if (!is_null($token->getAccessToken())) {
$this->facebook->setAccessToken($token->getAccessToken());
}
if ($uid = $this->facebook->getUser()) {
$newToken = $this->createAuthenticatedToken($uid, $token->getAccessToken());
$newToken->setAttributes($token->getAttributes());
return $newToken;
}
throw new AuthenticationException('The Facebook user could not be retrieved from the session.');
}