本文整理汇总了PHP中HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface::getTokenSecret方法的典型用法代码示例。如果您正苦于以下问题:PHP UserResponseInterface::getTokenSecret方法的具体用法?PHP UserResponseInterface::getTokenSecret怎么用?PHP UserResponseInterface::getTokenSecret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface
的用法示例。
在下文中一共展示了UserResponseInterface::getTokenSecret方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadUserByOAuthUserResponse
/**
* {@inheritdoc}
*/
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$username = $response->getNickname();
$twitterId = $response->getUsername();
$accessToken = $response->getAccessToken();
$secretToken = $response->getTokenSecret();
$user = $this->userManager->findUserByUsername($username);
//when the user is registrating
if (is_null($user)) {
// create new user here
$user = $this->userManager->createUser();
$user->setUsername($username);
$user->setAccessToken($accessToken);
$user->setTwitterId($twitterId);
$user->setSecretToken($secretToken);
//I have set all requested data with the user's username
//modify here with relevant data
$user->setEmail($username);
$user->setPlainPassword($username);
$user->setEnabled(true);
$this->userManager->updateUser($user);
return $user;
}
//if user exists - go with the HWIOAuth way
$user->setAccessToken($accessToken);
$user->setSecretToken($secretToken);
return $user;
}
示例2: loadUserByOAuthUserResponse
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$uri = $this->request->getUri();
$isFacebook = false;
$isGoogle = false;
$isLive = false;
$isTwitter = false;
if (strpos($uri, '/login_google') !== false) {
$isGoogle = true;
}
if (strpos($uri, '/login_facebook') !== false) {
$isFacebook = true;
}
if (strpos($uri, '/login_live') !== false) {
$isLive = true;
}
if (strpos($uri, '/login/check-twitter') !== false) {
$isTwitter = true;
}
if ($isGoogle === false && $isFacebook === false && $isLive === false && $isTwitter === false) {
throw new \Exception("Invalid social network login attempt");
}
$social = "";
if ($isGoogle) {
$social = "google";
}
if ($isFacebook) {
$social = "facebook";
}
if ($isLive) {
$social = "live";
}
if ($isTwitter) {
$social = "twitter";
}
//check to see if the user is logged in and if she is logged in with the same social network
$isLoggedInAlready = $this->session->has('user');
$isLoggedInAlreadyId = $this->session->get('user')['id'];
if ($isLoggedInAlready && $this->session->get('user')['social'] == $social) {
return $this->loadUserByUsername($isLoggedInAlreadyId);
}
$social_id = $response->getUsername();
$nickname = $response->getNickname();
$realName = $response->getRealName();
$email = $response->getEmail();
$avatar = $response->getProfilePicture();
//set data in session. upon logging out we just erase the whole array.
$sessionData = array();
$sessionData['social_id'] = $social_id;
$sessionData['nickname'] = $nickname;
$sessionData['realName'] = $realName;
$sessionData['email'] = $email;
$sessionData['avatar'] = $avatar;
$sessionData['social'] = $social;
$user = null;
if ($isLoggedInAlready) {
$user = $this->doctrine->getRepository('AppBundle\\Entity\\User')->findOneById($isLoggedInAlreadyId);
} else {
if ($isFacebook) {
$user = $this->doctrine->getRepository('AppBundle\\Entity\\User')->findOneByFid($social_id);
} else {
if ($isGoogle) {
$user = $this->doctrine->getRepository('AppBundle\\Entity\\User')->findOneByGid($social_id);
} else {
if ($isLive) {
$user = $this->doctrine->getRepository('AppBundle\\Entity\\User')->findOneByLid($social_id);
} else {
if ($isTwitter) {
$user = $this->doctrine->getRepository('AppBundle\\Entity\\User')->findOneByTid($social_id);
}
}
}
}
}
if ($user == null) {
$user = new User();
$user->setSecret($response->getTokenSecret());
$user->setToken($response->getAccessToken());
//change these only the user hasn't been registered before.
}
if ($isFacebook) {
$user->setFid($social_id);
} else {
if ($isGoogle) {
$user->setGid($social_id);
} else {
if ($isLive) {
$user->setLid($social_id);
} else {
if ($isTwitter) {
$user->setTid($social_id);
}
}
}
}
//$user->setLastLogin(new \DateTime('now'));
//$user->setSocial($social);
// SET E-MAIL
//if all emails are empty, set the first one to this one.
//save all changes
//.........这里部分代码省略.........