/** * Returns user info * * @return Apishka_SocialLogin_User */ public function getUserInfo() { $url = new \GuzzleHttp\Psr7\Uri($this->getProfileInfoUrl()); $info = $this->makeRequest($url, 'get', array('token' => $this->getStorage()->get($this->getAlias(), 'oauth_token'), 'token_secret' => $this->getStorage()->get($this->getAlias(), 'oauth_token_secret'))); $data = json_decode($info, true); $user = new Apishka_SocialLogin_User($data); $user->setId($data['id'])->setFullname($data['name'])->setLogin($data['screen_name'])->setAvatar($data['profile_image_url_https']); return $user; }
/** * Returns user info * * @return Apishka_SocialLogin_User */ public function getUserInfo() { $url = new \GuzzleHttp\Psr7\Uri($this->getProfileInfoUrl()); $url = $url->withQuery(http_build_query(array('format' => 'json', 'oauth_token' => $this->getStorage()->get($this->getAlias(), 'access_token')))); $info = $this->makeRequest($url); $data = json_decode($info, true); $user = new Apishka_SocialLogin_User($data); $user->setId($data['id'])->setFullname($data['real_name'])->setGender($data['sex'] == 'female' ? Apishka_SocialLogin_User::GENDER_FEMALE : Apishka_SocialLogin_User::GENDER_MALE)->setLogin($data['login'])->setBirthday($data['birthday'])->setEmail($data['default_email']); return $user; }
/** * Returns user info * * @return Apishka_SocialLogin_User */ public function getUserInfo() { $url = new \GuzzleHttp\Psr7\Uri($this->getProfileInfoUrl()); $url = $url->withQuery(http_build_query(array('uid' => $this->getAuthData()['user_id'], 'fields' => 'first_name,last_name,nickname,screen_name,sex,bdate,photo_big', 'access_token' => $this->getStorage()->get($this->getAlias(), 'access_token')))); $info = $this->makeRequest($url); $decode = json_decode($info, true); $data = $decode['response'][0]; $user = new Apishka_SocialLogin_User($data); $user->setId($data['uid'])->setAvatar($data['photo_big'])->setFullname($data['first_name'] . ' ' . $data['last_name'])->setFirstName($data['first_name'])->setLastName($data['last_name'])->setGender($data['sex'] == 2 ? Apishka_SocialLogin_User::GENDER_MALE : Apishka_SocialLogin_User::GENDER_FEMALE)->setLogin($data['nickname'])->setBirthday($data['bdate']); return $user; }
/** * Returns user info * * @return Apishka_SocialLogin_User */ public function getUserInfo() { $url = new \GuzzleHttp\Psr7\Uri($this->getProfileInfoUrl()); $url = $url->withQuery(http_build_query(array('format' => 'json', 'oauth2_access_token' => $this->getStorage()->get($this->getAlias(), 'access_token')))); $info = $this->makeRequest($url); $data = json_decode($info, true); $user = new Apishka_SocialLogin_User($data); $dob = count($data['dateOfBirth'] == 2) ? implode('-', $data['dateOfBirth']) . '-0000' : implode('-', $data['dateOfBirth']); $user->setId($data['id'])->setFullname($data['firstName'] . ' ' . $data['lastName'])->setFirstName($data['firstName'])->setLastName($data['lastName'])->setBirthday($dob)->setEmail($data['emailAddress'])->setAvatar($data['pictureUrl']); return $user; }
/** * Returns user info * * @return Apishka_SocialLogin_User */ public function getUserInfo() { $url = new \GuzzleHttp\Psr7\Uri($this->getProfileInfoUrl()); $url = $url->withQuery(http_build_query(array('oauth_token' => $this->getStorage()->get($this->getAlias(), 'access_token')))); $info = $this->makeRequest($url); $data = json_decode($info, true); if (!isset($data['id'])) { throw new Apishka_SocialLogin_Exception('Data retrieval error'); } $user = new Apishka_SocialLogin_User($data); $user->setId($data['id'])->setAvatar($data['image']['url'])->setFullname($data['name']['givenName'] . ' ' . $data['name']['familyName'])->setFirstName($data['name']['givenName'])->setLastName($data['name']['familyName'])->setGender($data['gender'] == 'female' ? Apishka_SocialLogin_User::GENDER_FEMALE : Apishka_SocialLogin_User::GENDER_MALE)->setLogin($data['nickname'])->setBirthday($data['birthday'])->setEmail($data['emails'][0]['value']); return $user; }
/** * Returns user info * * @return Apishka_SocialLogin_User */ public function getUserInfo() { $params = array('client_id' => $this->getProviderConfig()['client_id'], 'format' => 'json', 'method' => 'users.getInfo', 'session_key' => $this->getStorage()->get($this->getAlias(), 'access_token'), 'secure' => 1); $params['sig'] = $this->buildSignature($params); $url = new \GuzzleHttp\Psr7\Uri($this->getProfileInfoUrl()); $url = $url->withQuery(http_build_query($params)); $info = $this->makeRequest($url); $decoded = json_decode($info, true); $data = $decoded[0]; $user = new Apishka_SocialLogin_User($data); $user->setId($data['uid'])->setEmail($data['email'])->setAvatar($data['pic'])->setFullname($data['first_name'] . ' ' . $data['last_name'])->setFirstName($data['first_name'])->setLastName($data['last_name'])->setGender($data['sex'] == 0 ? Apishka_SocialLogin_User::GENDER_MALE : Apishka_SocialLogin_User::GENDER_FEMALE)->setLogin($data['nick'])->setBirthday($data['birthday']); return $user; }
/** * Returns user info * * @return Apishka_SocialLogin_User */ public function getUserInfo() { $fb = $this->getFBObject(); try { $response = $fb->get('/me?fields=id,name,email,gender', $this->getFacebookToken()->getValue()); } catch (Facebook\Exceptions\FacebookResponseException $exception) { throw new Apishka_SocialLogin_Exception('Provider return an error', 0, $exception); } catch (Facebook\Exceptions\FacebookSDKException $exception) { throw new Apishka_SocialLogin_Exception('Provider return an error', 0, $exception); } $data = $response->getGraphUser()->asArray(); $user = new Apishka_SocialLogin_User($data); $user->setId($data['id'])->setEmail($data['email'])->setAvatar('https://graph.facebook.com/' . $data['id'] . '/picture?type=large')->setFullname($data['name'])->setFirstName($data['first_name'])->setLastName($data['last_name'])->setGender($data['gender'] == 'female' ? Apishka_SocialLogin_User::GENDER_FEMALE : Apishka_SocialLogin_User::GENDER_MALE)->setBirthday($data['birthday']); return $user; }
/** * Returns user info * * @return Apishka_SocialLogin_User */ public function getUserInfo() { if (!array_key_exists('client_key', $this->getProviderConfig())) { throw new Apishka_SocialLogin_Exception('For odnoklassniki you have to define client_key in provider config'); } $params = array('application_key' => $this->getProviderConfig()['client_key'], 'method' => 'users.getCurrentUser', 'fields' => 'uid,first_name,last_name,name,gender,age,birthday,pic_4,email'); $params['sig'] = $this->buildSignature($params); $params['access_token'] = $this->getStorage()->get($this->getAlias(), 'access_token'); $url = new \GuzzleHttp\Psr7\Uri($this->getProfileInfoUrl()); $url = $url->withQuery(http_build_query($params)); $info = $this->makeRequest($url); $data = json_decode($info, true); if (!array_key_exists('uid', $data)) { throw new Apishka_SocialLogin_Exception('API error: ' . var_export($info, true)); } $user = new Apishka_SocialLogin_User($data); $user->setId($data['uid'])->setAvatar($data['pic_4'])->setFullname($data['name'])->setFirstName($data['first_name'])->setLastName($data['last_name'])->setGender($data['gender'] == 'male' ? Apishka_SocialLogin_User::GENDER_MALE : Apishka_SocialLogin_User::GENDER_FEMALE)->setBirthday($data['birthday']); return $user; }