Example #1
0
 public function request($arg)
 {
     if ($err = parent::request($arg)) {
         return $err;
     }
     $code = $_REQUEST['code'];
     $resp = http::post('https://accounts.google.com/o/oauth2/token', array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url, 'grant_type' => 'authorization_code'));
     if ($resp) {
         $tokens = json_decode($resp);
         if ($r = http::get('https://www.googleapis.com/oauth2/v1/userinfo?access_token=' . $tokens->access_token)) {
             $info = json_decode($r);
             return $this->adduser(array('service' => $this->name, 'email' => isset($info->email) ? $info->email : '', 'name' => $info->name, 'website' => isset($info->link) ? $info->link : ''), $info);
         }
     }
     return $this->errorauth();
 }
Example #2
0
 public function request($arg)
 {
     if ($err = parent::request($arg)) {
         return $err;
     }
     $code = $_REQUEST['code'];
     $resp = http::post('https://oauth.yandex.ru/token', array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'grant_type' => 'authorization_code'));
     if ($resp) {
         $tokens = json_decode($resp);
         if ($r = http::get('https://login.yandex.ru/info?format=json&oauth_token=' . $tokens->access_token)) {
             $info = json_decode($r);
             return $this->adduser(array('service' => $this->name, 'uid' => $info->id, 'email' => isset($info->default_email) ? $info->default_email : $info->emails[0], 'name' => isset($info->real_name) ? $info->real_name : $info->display_name), $info);
         }
     }
     return $this->errorauth();
 }
 public function request($arg)
 {
     if ($err = parent::request($arg)) {
         return $err;
     }
     $code = $_REQUEST['code'];
     $resp = http::get('https://graph.facebook.com/oauth/access_token?' . http_build_query(array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url)));
     if ($resp) {
         $params = null;
         parse_str($resp, $params);
         if ($r = http::get('https://graph.facebook.com/me?access_token=' . $params['access_token'])) {
             $info = json_decode($r);
             return $this->adduser(array('service' => $this->name, 'uid' => isset($info->id) ? $info->id : '', 'email' => isset($info->email) ? $info->email : '', 'name' => $info->name, 'website' => isset($info->link) ? $info->link : ''), $info);
         }
     }
     return $this->errorauth();
 }
 public function request($arg)
 {
     if ($err = parent::request($arg)) {
         return $err;
     }
     $code = $_REQUEST['code'];
     $resp = http::post('https://oauth.vk.com/access_token', array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url));
     if ($resp) {
         $tokens = json_decode($resp);
         if ($r = http::get('https://api.vk.com/method/getProfiles?uids=' . $tokens->user_id . '&access_token=' . $tokens->access_token)) {
             $js = json_decode($r);
             $info = $js->response[0];
             return $this->adduser(array('service' => $this->name, 'uid' => $info->uid, 'name' => $info->first_name . ' ' . $info->last_name, 'website' => 'http://vk.com/id' . $info->uid), $info);
         }
     }
     return $this->errorauth();
 }
Example #5
0
 public function request($arg)
 {
     if ($err = parent::request($arg)) {
         return $err;
     }
     $code = $_REQUEST['code'];
     $resp = http::post('https://connect.mail.ru/oauth/token', array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url, 'grant_type' => 'authorization_code'));
     if ($resp) {
         $tokens = json_decode($resp);
         $params = array('method' => 'users.getInfo', 'app_id' => $this->client_id, 'session_key' => $tokens->access_token, 'uids' => $tokens->x_mailru_vid, 'secure' => '1', 'format' => 'json');
         ksort($params);
         $params['sig'] = $this->sign($params, $this->client_secret);
         if ($r = http::get('http://www.appsmail.ru/platform/api?' . http_build_query($params))) {
             $js = json_decode($r);
             $info = $js[0];
             return $this->adduser(array('uid' => $info->uid, 'email' => isset($info->email) ? $info->email : '', 'name' => $info->nick, 'website' => isset($info->link) ? $info->link : ''), $info);
         }
     }
     return $this->errorauth();
 }
 public function request($arg)
 {
     if ($err = parent::request($arg)) {
         return $err;
     }
     $code = $_REQUEST['code'];
     $resp = http::post('http://api.odnoklassniki.ru/oauth/token.do', array('grant_type' => 'authorization_code', 'code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url . litepublisher::$site->q . 'state=' . $_GET['state']));
     if ($resp) {
         $tokens = json_decode($resp);
         if (isset($tokens->error)) {
             return 403;
         }
         $params = array('application_key' => $this->public_key, 'client_id' => $this->client_id, 'method' => 'users.getCurrentUser', 'format' => 'JSON');
         $params['sig'] = strtolower($this->sign($params, md5($tokens->access_token . $this->client_secret)));
         $params['access_token'] = $tokens->access_token;
         if ($r = http::post('http://api.odnoklassniki.ru/fb.do', $params)) {
             $js = json_decode($r);
             if (!isset($js->error)) {
                 return $this->adduser(array('uid' => $js->uid, 'name' => $js->name, 'website' => isset($js->link) ? $js->link : ''), $js);
             }
         }
     }
     return $this->errorauth();
 }