Esempio n. 1
0
 public function __token()
 {
     $code =& $_GET['code'];
     if (isset($code)) {
         // Send http get request to retrieve VK code
         $token = $this->post($this->tokenURL, array('client_id' => $this->appCode, 'client_secret' => $this->appSecret, 'code' => $code, 'redirect_uri' => $this->returnURL(), 'grant_type' => 'authorization_code'));
         // take user's information using access token
         if (isset($token['access_token'])) {
             $userInfo = $this->get($this->userURL, array('access_token' => $token['access_token']));
             $this->setUser($userInfo);
         }
     }
     parent::__token();
 }
 public function __token()
 {
     $code = $_GET['code'];
     if (isset($code)) {
         // Send http get request to retrieve VK code
         $token = $this->post($this->tokenURL, array('code' => $code, 'redirect_uri' => $this->returnURL(), 'grant_type' => 'authorization_code', 'client_id' => $this->appCode, 'client_secret' => $this->appSecret));
         // take user's information using access token
         if (isset($token)) {
             $sig = md5('application_key=' . $this->publicKey . 'method=users.getCurrentUser' . md5($token['access_token'] . $this->appSecret));
             $userInfo = $this->get($this->userURL, array('method' => 'users.getCurrentUser', 'access_token' => $token['access_token'], 'application_key' => $this->publicKey, 'sig' => $sig));
             $this->setUser($userInfo);
         }
     }
     parent::__token();
 }
Esempio n. 3
0
 public function __token()
 {
     /* Create a TwitterOauth object with consumer/user tokens. */
     $connection = new TwitterOAuth($this->appCode, $this->appSecret, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
     /* Request access tokens from twitter */
     $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
     // Save access token to session
     $this->token = $access_token;
     $_SESSION[self::SESSION_PREFIX . '_' . $this->id] = $access_token;
     /* Get logged in user to help with tests. */
     $user = $connection->get('account/verify_credentials');
     // Covert user data to generic user object
     if ($user) {
         $this->setUser((array) $user);
     }
     parent::__token();
 }
Esempio n. 4
0
 public function __token()
 {
     $code =& $_GET['code'];
     if (isset($code)) {
         // Send http get request to retrieve VK code
         $token = $this->post($this->tokenURL, array('client_id' => $this->appCode, 'client_secret' => $this->appSecret, 'code' => $code, 'redirect_uri' => $this->returnURL()));
         // take user's information using access token
         if (isset($token['access_token'])) {
             // Perform API request to get user data
             $request = $this->get($this->userURL, array('uids' => $token['user_id'], 'fields' => 'uid,first_name,last_name,screen_name,sex,bdate,photo', 'access_token' => $token['access_token']));
             // Save access token to session
             $this->token = $token['access_token'];
             $_SESSION[self::SESSION_PREFIX . '_' . $this->id] = $this->token;
             // If we have successfully received user data
             if (isset($request['response'][0])) {
                 $this->setUser($request, $this->user);
             }
         }
     }
     // Call standard behaviour
     parent::__token();
 }