示例#1
0
 function oauth()
 {
     session();
     if (empty($_GET['s']) or $_GET['s'] == 'sina') {
         $conf = $this->config['oauth']['weibo'];
         $oauth = new WeiboOAuth($conf['appid'], $conf['skey']);
         $keys = $oauth->getRequestToken();
         $_SESSION['oauth_keys'] = $keys;
         $_SESSION['oauth_serv'] = 'sina';
         $login_url = $oauth->getAuthorizeURL($keys['oauth_token'], false, WEBROOT . '/page/oauth_callback/');
         $this->swoole->http->redirect($login_url);
     } elseif ($_GET['s'] == 'qq') {
         $conf = $this->config['oauth']['qq'];
         $oauth = new QQOAuth($conf['APP_ID'], $conf['APP_KEY']);
         $token = $oauth->getRequestToken();
         $_SESSION['oauth_keys'] = $token;
         $_SESSION['oauth_serv'] = 'qq';
         $login_url = $oauth->getAuthorizeURL($token, WEBROOT . '/page/oauth_callback/');
         $this->swoole->http->redirect($login_url);
     }
 }
示例#2
0
 function _get_oauth_url()
 {
     $callback = $this->Config['site_url'] . "/index.php?mod=qqwb&code=auth_callback";
     require_once ROOT_PATH . 'include/ext/qqwb/qqoauth.php';
     $QQAuth = new QQOAuth($this->QQWBConfig['app_key'], $this->QQWBConfig['app_secret']);
     $keys = $QQAuth->getRequestToken($callback);
     $_SESSION['qqwb_oauth_token_secret'] = $keys['oauth_token_secret'];
     jsg_setcookie('qqwb_oauth_token_secret', $_SESSION['qqwb_oauth_token_secret']);
     $aurl = $QQAuth->getAuthorizeURL($keys['oauth_token'], $callback);
     return $aurl;
 }