当前位置: 首页>>代码示例>>PHP>>正文


PHP UserResponseInterface::getResponse方法代码示例

本文整理汇总了PHP中HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface::getResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP UserResponseInterface::getResponse方法的具体用法?PHP UserResponseInterface::getResponse怎么用?PHP UserResponseInterface::getResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface的用法示例。


在下文中一共展示了UserResponseInterface::getResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loginUserGoogle

 private function loginUserGoogle(UserResponseInterface $response)
 {
     $username = $response->getUsername();
     $firstName = $response->getResponse()['given_name'];
     $lastName = $response->getResponse()['family_name'];
     $gender = $response->getResponse()['gender'];
     $email = $response->getEmail();
     return ['loginField' => 'googleLogin', 'username' => $username, 'firstName' => $firstName, 'lastName' => $lastName, 'gender' => $gender, 'email' => $email];
 }
开发者ID:rotanov,项目名称:fefu-social-network,代码行数:9,代码来源:OAuthUserProvider.php

示例2: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $authProviderName = $response->getResourceOwner()->getName();
     switch ($authProviderName) {
         case 'github':
             $username = $response->getResponse()['login'];
             break;
         case 'twitter':
             $username = $response->getResponse()['screen_name'];
             break;
     }
     $this->session->set('owner', $authProviderName);
     $this->session->set('username', $username);
     return $this->loadUserByUsername($username);
 }
开发者ID:vreemt,项目名称:haphpy-birthday,代码行数:18,代码来源:UserProvider.php

示例3: importProfileLinkedinAction

 public function importProfileLinkedinAction(Request $request, UserResponseInterface $response)
 {
     $data = $response->getResponse();
     /* this method should return all data that was sent from resource owner ???*/
     var_dump($data);
     exit;
 }
开发者ID:medy36,项目名称:OauthSymfony,代码行数:7,代码来源:DefaultController.php

示例4: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     #        $username = $response->getUsername();
     #        var_dump($username);exit;
     $username = $response->getResponse()["username"];
     var_dump($username);
     $user = $this->userManager->findUserBy(array('username' => $username));
     //when the user is registrating
     if (null === $user) {
         $service = $response->getResourceOwner()->getName();
         $setter = 'set' . ucfirst($service);
         $setter_id = $setter . 'Id';
         $setter_token = $setter . 'AccessToken';
         // create new user here
         $user = $this->userManager->createUser();
         $user->{$setter_id}($username);
         $user->{$setter_token}($response->getAccessToken());
         //I have set all requested data with the user's username
         //modify here with relevant data
         $user->setUsername($username);
         #    $user->setNickname($response->getNickName());
         $user->setEmail($username . '@yoursite.com');
         $user->setPassword($username);
         #    $user->setPath($response->getProfilePicture());
         $user->setEnabled(true);
         $this->userManager->updateUser($user);
         return $user;
     }
     //if user exists - go with the HWIOAuth way
     $serviceName = $response->getResourceOwner()->getName();
     $setter = 'set' . ucfirst($serviceName) . 'AccessToken';
     //update access token
     $user->{$setter}($response->getAccessToken());
     return $user;
 }
开发者ID:michaelwang,项目名称:openshop,代码行数:35,代码来源:Member.php

示例5: handleResponse

 public function handleResponse(UserResponseInterface $response, UserService $userService)
 {
     $fields = $response->getResponse();
     $gitHubLogin = $fields['login'];
     $accessToken = $response->getAccessToken();
     $user = $userService->findByGitHubLogin($gitHubLogin);
     if (null === $user) {
         throw new UsernameNotFoundException();
     }
     $oAuthUser = new OAuthUser($user);
     $oAuthUser->addRole('ROLE_GITHUB_USER');
     $oAuthUser->setAccessToken($accessToken);
     if (array_key_exists('name', $fields)) {
         $gitHubName = $fields['name'];
         $oAuthUser->setRealName($gitHubName);
     } else {
         $oAuthUser->setRealName($gitHubLogin);
     }
     $client = new Client();
     $client->setOption('api_version', 'v3');
     $client->authenticate($response->getAccessToken(), Client::AUTH_HTTP_TOKEN);
     /* @var \Github\Api\CurrentUser $currentUserApi */
     $currentUserApi = $client->api('current_user');
     $emails = $currentUserApi->emails();
     $allEMails = $emails->all();
     $oAuthUser->setEmail($this->getPrimaryEmailAddress($allEMails));
     return $oAuthUser;
 }
开发者ID:terretta,项目名称:gitki.php,代码行数:28,代码来源:GitHubResponseHandler.php

示例6: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     // echa($response->getAccessToken());
     // 		echa($response->getResponse(), __FILE__);
     // -- Load user's data from P4S
     $data = $response->getResponse();
     if (null != $data && array_key_exists('status', $data) && ResponseHelper::OK == $data['status'] && array_key_exists('data', $data) && null != $data['data']) {
         $p4sId = $data['data']['id'];
     } else {
         throw new UsernameNotFoundException("Unable to load this user info");
     }
     $result = $this->em->getRepository('Amisure\\P4SApiBundle\\Entity\\User\\SessionUser')->findOneBy(array('username' => $p4sId));
     // - Create an account
     if (null == $result) {
         $user = $this->fillUser($data['data']);
         $this->createNewUser($user);
     } else {
         // $user = $result;
         $user = $this->fillUser($data['data']);
         $user->setId($result->getId());
     }
     // -- Save access token
     $this->session->set('access_token', $response->getAccessToken());
     return $user;
 }
开发者ID:trialog,项目名称:p4s-api-bundle,代码行数:25,代码来源:UserProvider.php

示例7: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     try {
         $resourceOwnerName = $response->getResourceOwner()->getName();
         if (!isset($this->properties[$resourceOwnerName])) {
             throw new \RuntimeException(sprintf("No property defined for entity for resource owner '%s'.", $resourceOwnerName));
         }
         $username = $response->getUsername();
         if (null === ($user = $this->repository->findOneBy(array($this->properties[$resourceOwnerName] => $username)))) {
             throw new UsernameNotFoundException(sprintf("User '%s' not found.", $username));
         }
         return $user;
     } catch (UsernameNotFoundException $e) {
         $rawResponse = $response->getResponse();
         $user = new User($rawResponse['screen_name']);
         $user->setTwitterId($rawResponse['id']);
         $user->setUsername($rawResponse['screen_name']);
         $user->setTodaySinceId('');
         $user->setIsActive(true);
         $user->setCreateAt(new \DateTime());
         $user->setUpdateAt(new \DateTime());
         $this->em->persist($user);
         $this->em->flush();
         return $user;
     }
 }
开发者ID:ryota-murakami,项目名称:daily-tweet,代码行数:26,代码来源:OAuthEntityUserProvider.php

示例8: 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());
 }
开发者ID:palmfjord,项目名称:sr-playlist,代码行数:16,代码来源:SpotifyOAuthUserProvider.php

示例9: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $content = $response->getResponse();
     $resourceOwner = $response->getResourceOwner();
     try {
         $user = $this->loadUserByServiceAndId($resourceOwner->getName(), $content['id']);
         return $user;
     } catch (\Exception $e) {
         $name = $response->getRealName();
         $nameArray = explode(' ', $name, 2);
         $firstName = $response->getFirstName();
         $lastName = $response->getLastName();
         if (empty($firstName) || empty($lastName)) {
             if (array_key_exists(0, $nameArray)) {
                 $firstName = ucfirst(strtolower($nameArray[0]));
             }
             if (array_key_exists(1, $nameArray)) {
                 $lastName = ucfirst(strtolower($nameArray[1]));
             }
         }
         $user = array();
         $user['firstName'] = $firstName;
         $user['lastName'] = $lastName;
         $user['username'] = $this->createUsername($response->getNickname());
         $user['mail'] = $response->getEmail();
         $this->session->set('icap.oauth.user', $user);
         $resourceOwnerArray = array('name' => $resourceOwner->getName(), 'id' => $content['id']);
         $this->session->set('icap.oauth.resource_owner', $resourceOwnerArray);
         throw $e;
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:34,代码来源:OauthUserProvider.php

示例10: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     //$doctrine = $em = $this->getEntityManager();
     //echo 'fsfd';
     //print_r($doctrine);
     //die;
     try {
         $userdata = $response->getResponse();
         $fbid = $userdata['id'];
         $name = $userdata['name'];
         $email = $userdata['email'];
         print_r($userdata);
         $user = $this->_em->createQueryBuilder()->select('u')->from('Yasoon\\Site\\Entity\\AuthorEntity', 'u')->where('u.facebookId = :fbid')->setParameter('fbid', $fbid)->getQuery()->getSingleResult();
         if (!is_object($user)) {
             $user = (new AuthorEntity())->setName($name)->setEmail('')->setPassword('')->setSubscribed(1)->setFacebookId($fbid)->setPublicationDate(new \DateTime())->setRole(1);
             $this->_em->persist($user);
             $this->_em->flush();
         }
     } catch (\Exception $e) {
         return ['error' => true, 'errorText' => $e->getMessage()];
     }
     //$user = $this->_em->getRepository('Yasoon\Site\Entity\AuthorEntity')->find(41);
     //print_r($user->getName());
     return $user;
 }
开发者ID:yasoon,项目名称:yasoon,代码行数:25,代码来源:AuthorFacebookRepository.php

示例11: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $data = $response->getResponse();
     $username = $response->getUsername();
     $email = $response->getEmail() ? $response->getEmail() : $username;
     $user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
     //when the user is registrating
     if (null === $user) {
         $service = $response->getResourceOwner()->getName();
         $setter = 'set' . ucfirst($service);
         $setter_id = $setter . 'Id';
         $setter_token = $setter . 'AccessToken';
         // create new user here
         $user = $this->userManager->createUser();
         $user->{$setter_id}($username);
         $user->{$setter_token}($response->getAccessToken());
         //I have set all requested data with the user's username
         //modify here with relevant data
         $user->setUsername($username);
         $user->setEmail($email);
         $user->setPassword($username);
         $user->setEnabled(true);
         $this->userManager->updateUser($user);
         return $user;
     }
     //if user exists - go with the HWIOAuth way
     $user = parent::loadUserByOAuthUserResponse($response);
     $serviceName = $response->getResourceOwner()->getName();
     $setter = 'set' . ucfirst($serviceName) . 'AccessToken';
     //update access token
     $user->{$setter}($response->getAccessToken());
     return $user;
 }
开发者ID:poteirard,项目名称:concert-autolist,代码行数:33,代码来源:FOSUBUserProvider.php

示例12: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $userEmail = $response->getEmail();
     $user = $this->userManager->findUserByEmail($userEmail);
     // if null just create new user and set it properties
     if (null === $user) {
         $userData = $response->getResponse();
         $user = new User();
         $user->setUsername($userData['formattedName']);
         $user->setPlainPassword(rand(1000000, 10000000));
         //TODO:find a better option
         //TODO: add location, company name, ..
         $user->setEmail($response->getEmail());
         $user->setEnabled(true);
         $this->userManager->updateUser($user);
         $this->em->flush();
         return $user;
     }
     // else update access token of existing user
     $serviceName = $response->getResourceOwner()->getName();
     $setter = 'set' . ucfirst($serviceName) . 'AccessToken';
     $user->{$setter}($response->getAccessToken());
     //update access token
     return $user;
 }
开发者ID:OpenSkills,项目名称:skillsprofile,代码行数:28,代码来源:MyFOSUBUserProvider.php

示例13: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $generator = new SecureRandom();
     $random = $generator->nextBytes(10);
     $data = $response->getResponse();
     $username = $response->getUsername();
     $email = $response->getEmail() ? $response->getEmail() : $username;
     $service = $response->getResourceOwner()->getName();
     $user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
     //$user = $this->userManager->findUserBy(array($service.'Id' => $username));
     //when the user is registrating
     if (null === $user) {
         $setter = 'set' . ucfirst($service);
         $setter_id = $setter . 'Id';
         $setter_token = $setter . 'AccessToken';
         // create new user here
         $user = $this->userManager->createUser();
         $user->{$setter_id}($username);
         $user->{$setter_token}($response->getAccessToken());
         $user->setUsername($email);
         $user->setEmail($email);
         $user->setPlainPassword($random);
         $user->setName($response->getRealName());
         $user->setEnabled(true);
         $this->userManager->updateUser($user);
         return $user;
     }
     //if user exists - go with the HWIOAuth way
     $user = parent::loadUserByOAuthUserResponse($response);
     $serviceName = $response->getResourceOwner()->getName();
     $setter = 'set' . ucfirst($serviceName) . 'AccessToken';
     //update access token
     $user->{$setter}($response->getAccessToken());
     return $user;
 }
开发者ID:roman-movchan,项目名称:salefactor,代码行数:35,代码来源:FOSUBUserProvider.php

示例14: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $data = $response->getResponse();
     $username = $response->getUsername();
     $user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
     $service = $response->getResourceOwner()->getName();
     //when the user is registrating
     if (null === $user) {
         if ($service == "google") {
             $service = "gplus";
         }
         $setter = 'set' . ucfirst($service);
         $setter_id = $setter . 'Uid';
         $setter_token = $setter . 'Name';
         // create new user here
         // TODO: Check email, if exist add service
         $userE = $this->userManager->findUserBy(array("email" => $response->getEmail()));
         if (null === $userE) {
             $user = $this->userManager->createUser();
             $user->setUsername($response->getEmail());
             if ($service == "gplus") {
                 $user->setFirstname($data['given_name']);
             }
             if ($service == "facebook") {
                 $name = explode(" ", $data['name']);
                 $user->setFirstname($name[0]);
                 $user->setLastname($name[1]);
             }
             $user->setEmail($response->getEmail());
             $user->setPassword("");
         } else {
             $user = $userE;
         }
         $user->{$setter_id}($username);
         $user->{$setter_token}($response->getAccessToken());
         $user->setEnabled(true);
         // Customfields
         $user->setProfilePicture($response->getProfilePicture());
         //TODO: Save Locale, $user->setLocale($response->getLocale());
         $this->userManager->updateUser($user);
         return $user;
     }
     //if user exists - go with the HWIOAuth way
     $user = parent::loadUserByOAuthUserResponse($response);
     $serviceName = $response->getResourceOwner()->getName();
     if ($serviceName == "google") {
         $serviceName = "gplus";
     }
     $setter = 'set' . ucfirst($serviceName) . 'Name';
     //update access token
     $user->{$setter}($response->getAccessToken());
     //update custom fields
     //TODO: Check google response, facebook?
     if ($service == "facebook") {
         $url = "http://graph.facebook.com/" . $data['id'] . "/picture?type=normal";
         $user->setProfilePicture($url);
     }
     return $user;
 }
开发者ID:alejandro-arrabal,项目名称:BasicSymfony,代码行数:62,代码来源:FOSUBUserProvider.php

示例15: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $authProviderName = $response->getResourceOwner()->getName();
     $username = $response->getResponse()['login'];
     $this->session->set('owner', $authProviderName);
     $this->session->set('username', $username);
     return $this->loadUserByUsername($username);
 }
开发者ID:ramondelafuente,项目名称:haphpy-birthday,代码行数:11,代码来源:UserProvider.php


注:本文中的HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface::getResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。