예제 #1
0
 /**
  * @return false|Model\User
  */
 public function getUserData()
 {
     try {
         $session = new \Facebook\FacebookSession($this->getAccessToken());
         $request = new \Facebook\FacebookRequest($session, 'GET', '/me');
         $response = $request->execute();
         $userData = $response->getResponse();
         $userModel = new Model\User();
         $userModel->setId($userData->id);
         $userModel->setEmail($userData->email);
         $userModel->setName($userData->name);
         $userModel->setGender($userData->gender);
         return $userModel;
     } catch (\Exception $e) {
         return false;
     }
 }
예제 #2
0
 /**
  * @return Model\User
  */
 public function getUserData()
 {
     if (!($accessTokenData = $this->getAccessToken())) {
         return false;
     }
     $data = array('accessToken' => $accessTokenData['access_token'], 'email' => $accessTokenData['email'], 'id' => $accessTokenData['user_id']);
     $user = $this->_vk->api('users.get', array('fields' => 'sex'))['response'][0];
     $userData = array_merge($data, $user);
     $userModel = new Model\User();
     $userModel->setId($userData['uid']);
     $userModel->setEmail($userData['email']);
     $userModel->setName(implode(' ', array($userData['first_name'], $userData['last_name'])));
     switch ($userData['sex']) {
         case '2':
             $userModel->setGender('male');
             break;
         case '1':
             $userModel->setGender('female');
             break;
     }
     return $userModel;
 }