getAuthorizeURL() 공개 메소드

return $this->authorizeURL() . "?oauth_token={$token}&oauth_callback=" . urlencode($url); }
public getAuthorizeURL ( $token )
예제 #1
0
		public function oauth() {
			pc_base::load_plugin_class('weibooauth','',0);
			$setting = getcache('weibo_var','plugins');			
			if(!isset($_REQUEST['oauth_verifier']) || $_REQUEST['oauth_verifier'] == '') {
				if($this->auth_db->get_one(array('source'=>'sina'))) {
					$txt = '授权成功,<a href="?m=zl_admin&c=plugin&a=config&pluginid='.$this->pluginid.'&module=removeauth&pc_hash='.$_SESSION['pc_hash'].'">解除绑定</a>';
				} else {
					$o = new WeiboOAuth( $setting['wb_akey'] , $setting['wb_skey']);
					$keys = $o->getRequestToken();
					print_r($keys);
					$aurl = $o->getAuthorizeURL( $keys['oauth_token'] ,false , get_url());
					$_SESSION['keys'] = $keys;
					$txt = '<a href="'.$aurl.'">点击进行授权</a>';
				}
				
			} else {
				$o = new WeiboOAuth( $setting['wb_akey'] , $setting['wb_skey'] , $_SESSION['keys']['oauth_token'] , $_SESSION['keys']['oauth_token_secret']  );
				$last_key = $o->getAccessToken(  $_REQUEST['oauth_verifier'] ) ;				
				$c = new WeiboClient( $setting['wb_akey'] , $setting['wb_skey'] , $last_key['oauth_token'] , $last_key['oauth_token_secret']  );
				$ms  = $c->home_timeline(); // done
				$me = $c->verify_credentials();	
				$this->auth_db->insert(array('uid'=>$me['id'],'token'=>$last_key['oauth_token'],'tsecret'=>$last_key['oauth_token_secret'],'source'=>'sina'));
				$txt = '授权成功,'.$me['name'].'<a href="?m=zl_admin&c=plugin&a=config&pluginid='.$this->pluginid.'&module=removeauth&pc_hash='.$_SESSION['pc_hash'].'">解除绑定</a>';
			}
			include $this->op->plugin_tpl('oauth',PLUGIN_ID);
		}
예제 #2
0
 function getLoginUrl()
 {
     $o = new WeiboOAuth(ISession::get('apiKey'), ISession::get('apiSecret'));
     $keys = $o->getRequestToken();
     $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, parent::getReturnUrl());
     $_SESSION['keys'] = $keys;
     return $aurl;
 }
예제 #3
0
 function getUrl()
 {
     $o = new WeiboOAuth(WB_AKEY, WB_SKEY);
     $keys = $o->getRequestToken();
     $sinaurl = $o->getAuthorizeURL($keys['oauth_token'], false, URL_CALLBACK);
     setcookie('keys[oauth_token]', $keys['oauth_token'], 0, '/');
     setcookie('keys[oauth_token_secret]', $keys['oauth_token_secret'], 0, '/');
     return $sinaurl;
 }
예제 #4
0
파일: sina.php 프로젝트: yunsite/snshub
 private function get_auth_url()
 {
     $o = new WeiboOAuth(WB_AKEY, WB_SKEY);
     $keys = $o->getRequestToken();
     $callback = site_url() . '/binding/sina/callback';
     $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $callback);
     //$_SESSION['oauth_keys'] = $keys;
     $this->session->set_userdata($keys);
     return $aurl;
 }
예제 #5
0
 private function jump()
 {
     global $_FANWE;
     $oauth = new WeiboOAuth($this->config['app_key'], $this->config['app_secret']);
     $keys = $oauth->getRequestToken();
     $url = $oauth->getAuthorizeURL($keys['oauth_token'], false, $_FANWE['site_url'] . "callback/sina.php");
     $url = FU('tgo', array('url' => $url));
     fSetCookie('login_oauth', authcode(serialize($keys), 'ENCODE', $_FANWE['authkey']));
     fHeader("location:" . $url);
 }
예제 #6
0
 function getUrl($call_back = null)
 {
     if (empty($this->_sina_akey) || empty($this->_sina_skey)) {
         return false;
     }
     if (is_null($call_back)) {
         $call_back = U('home/public/callback');
     }
     $o = new WeiboOAuth($this->_sina_akey, $this->_sina_skey);
     $keys = $o->getRequestToken();
     $this->loginUrl = $o->getAuthorizeURL($keys['oauth_token'], false, $call_back);
     $_SESSION['sina']['keys'] = $keys;
     return $this->loginUrl;
 }
    /**
     * 这个数据显示一个页面,它自动会转入新浪授权的页面
     */
    function showSinaAuth()
    {
        $o = new WeiboOAuth(WB_AKEY, WB_SKEY);
        $keys = $o->getRequestToken();
        $u =& JFactory::getURI();
        $p = $u->base();
        $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $p . '/index.php?option=com_weibo&task=sinacallback');
        $_SESSION['keys'] = $keys;
        ?>
<script>
document.location.href="<?php 
        echo $aurl;
        ?>
"
</script>
		<?php 
    }
예제 #8
0
파일: page.php 프로젝트: netstao/swoole.com
 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);
     }
 }
예제 #9
0
파일: index.php 프로젝트: yunsite/micro-fan
 $user = mysql_fetch_array($user);
 $userid = $user['administrator'];
 $nickname = $user['nickname'];
 $email = $user['mail'];
 $microblog = unserialize($user['microblog']);
 /*$sina = unserialize($user['sina']);
   $tecent = unserialize($user['tecent']);
   $wangyi = unserialize($user['wangyi']);*/
 $xiami = $user['xiami'];
 $douban = $user['douban'];
 $photo = $user['photo'];
 //sina weibo
 $sina_o = new WeiboOAuth(WB_AKEY, WB_SKEY);
 $sina_keys = $sina_o->getRequestToken();
 $sina_callback = MF_URL . 'action.php?act=sina_oauth';
 $sina_aurl = $sina_o->getAuthorizeURL($sina_keys['oauth_token'], false, $sina_callback);
 $_SESSION['sina_keys'] = $sina_keys;
 //qq weibo
 echo '<span style="display:none;">';
 $tecent_o = new MBOpenTOAuth(MB_AKEY, MB_SKEY);
 $tecent_keys = $tecent_o->getRequestToken(MF_URL . 'action.php?act=qq_oauth');
 $tecent_aurl = $tecent_o->getAuthorizeURL($tecent_keys['oauth_token'], false, '');
 $_SESSION['tecent_keys'] = $tecent_keys;
 echo '</span>';
 //163 weibo
 echo '<span style="display:none;">';
 $wangyi_o = new wy_WeiboOAuth(WY_AKEY, WY_SKEY);
 $wangyi_keys = $wangyi_o->getRequestToken();
 $wangyi_callback = MF_URL . 'action.php?act=163_oauth';
 $wangyi_aurl = $wangyi_o->getAuthorizeURL($wangyi_keys['oauth_token'], true, $wangyi_callback);
 $_SESSION['wangyi_keys'] = $wangyi_keys;
예제 #10
0
<?php

require_once dirname(__FILE__) . '/config.php';
$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
$keys = $o->getRequestToken();
$aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $INI['system']['wwwprefix'] . '/thirdpart/sina/callback.php');
$_SESSION['keys'] = $keys;
redirect($aurl);
예제 #11
0
<?php

@header('Content-Type:text/html;charset=utf-8');
session_start();
include_once 'config.php';
include_once 'txwboauth.php';
$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
$keys = $o->getRequestToken($INI['system']['wwwprefix'] . '/thirdpart/qq/callback.php');
//这里填上你的回调URL
$aurl = $o->getAuthorizeURL($keys['oauth_token'], false, '');
$_SESSION['keys'] = $keys;
redirect($aurl);
function oauth_sina()
{
    include_once 'sinaoauth.inc.php';
    $o = new WeiboOAuth(SINA_AKEY, SINA_SKEY);
    $keys = $o->getRequestToken();
    $callback = BASE_URL . "sina_callback";
    $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $callback);
    $_SESSION['sinakeys'] = $keys;
    header("Location: {$aurl}");
}
예제 #13
0
파일: index.php 프로젝트: boylzj/omguitar
 /**
  * QQ微博登录
  */
 public function public_qq_login()
 {
     define('QQ_AKEY', pc_base::load_config('system', 'qq_akey'));
     define('QQ_SKEY', pc_base::load_config('system', 'qq_skey'));
     pc_base::load_app_class('qqoauth', '', 0);
     $this->_session_start();
     if (isset($_GET['callback']) && trim($_GET['callback'])) {
         $o = new WeiboOAuth(QQ_AKEY, QQ_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
         $_SESSION['last_key'] = $o->getAccessToken($_REQUEST['oauth_verifier']);
         if (!empty($_SESSION['last_key']['name'])) {
             //检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
             $where = array('connectid' => $_REQUEST['openid'], 'from' => 'qq');
             $r = $this->db->get_one($where);
             //connect用户已经绑定本站用户
             if (!empty($r)) {
                 //读取本站用户信息,执行登录操作
                 $password = $r['password'];
                 $this->_init_phpsso();
                 $synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
                 $userid = $r['userid'];
                 $groupid = $r['groupid'];
                 $username = $r['username'];
                 $nickname = empty($r['nickname']) ? $username : $r['nickname'];
                 $this->db->update(array('lastip' => ip(), 'lastdate' => SYS_TIME, 'nickname' => $me['name']), array('userid' => $userid));
                 if (!$cookietime) {
                     $get_cookietime = param::get_cookie('cookietime');
                 }
                 $_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
                 $cookietime = $_cookietime ? TIME + $_cookietime : 0;
                 $phpcms_auth = sys_auth($userid . "\t" . $password, 'ENCODE', get_auth_key('login'));
                 param::set_cookie('auth', $phpcms_auth, $cookietime);
                 param::set_cookie('_userid', $userid, $cookietime);
                 param::set_cookie('_username', $username, $cookietime);
                 param::set_cookie('_groupid', $groupid, $cookietime);
                 param::set_cookie('cookietime', $_cookietime, $cookietime);
                 param::set_cookie('_nickname', $nickname, $cookietime);
                 param::set_cookie('_from', 'snda');
                 $forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
                 showmessage(L('login_success') . $synloginstr, $forward);
             } else {
                 //弹出绑定注册页面
                 $_SESSION = array();
                 $_SESSION['connectid'] = $_REQUEST['openid'];
                 $_SESSION['from'] = 'qq';
                 $connect_username = $_SESSION['last_key']['name'];
                 //加载用户模块配置
                 $member_setting = getcache('member_setting');
                 if (!$member_setting['allowregister']) {
                     showmessage(L('deny_register'), 'index.php?m=member&c=index&a=login');
                 }
                 //获取用户siteid
                 $siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
                 //过滤非当前站点会员模型
                 $modellist = getcache('member_model', 'commons');
                 foreach ($modellist as $k => $v) {
                     if ($v['siteid'] != $siteid || $v['disabled']) {
                         unset($modellist[$k]);
                     }
                 }
                 if (empty($modellist)) {
                     showmessage(L('site_have_no_model') . L('deny_register'), HTTP_REFERER);
                 }
                 $modelid = 10;
                 //设定默认值
                 if (array_key_exists($modelid, $modellist)) {
                     //获取会员模型表单
                     require CACHE_MODEL_PATH . 'member_form.class.php';
                     $member_form = new member_form($modelid);
                     $this->db->set_model($modelid);
                     $forminfos = $forminfos_arr = $member_form->get();
                     //万能字段过滤
                     foreach ($forminfos as $field => $info) {
                         if ($info['isomnipotent']) {
                             unset($forminfos[$field]);
                         } else {
                             if ($info['formtype'] == 'omnipotent') {
                                 foreach ($forminfos_arr as $_fm => $_fm_value) {
                                     if ($_fm_value['isomnipotent']) {
                                         $info['form'] = str_replace('{' . $_fm . '}', $_fm_value['form'], $info['form']);
                                     }
                                 }
                                 $forminfos[$field]['form'] = $info['form'];
                             }
                         }
                     }
                     $formValidator = $member_form->formValidator;
                 }
                 include template('member', 'connect');
             }
         } else {
             showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
         }
     } else {
         $oauth_callback = APP_PATH . 'index.php?m=member&c=index&a=public_qq_login&callback=1';
         $oauth_nonce = md5(SYS_TIME);
         $oauth_signature_method = 'HMAC-SHA1';
         $oauth_timestamp = SYS_TIME;
         $oauth_version = '1.0';
         $url = "https://open.t.qq.com/cgi-bin/request_token?oauth_callback={$oauth_callback}&oauth_consumer_key=" . QQ_AKEY . "&oauth_nonce={$oauth_nonce}&oauth_signature=" . QQ_SKEY . "&oauth_signature_method=HMAC-SHA1&oauth_timestamp={$oauth_timestamp}&oauth_version={$oauth_version}";
         $o = new WeiboOAuth(QQ_AKEY, QQ_SKEY);
         $keys = $o->getRequestToken(array('callback' => $oauth_callback));
         $_SESSION['keys'] = $keys;
         $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $oauth_callback);
         include template('member', 'connect_qq');
     }
 }
예제 #14
0
<?php

/*
 * suggestion steps:
 * 1,curl this page and get the aurl;
 * 2,use curl to post the auth message "user/pwd" from aurl and try to get the content of page "callback.php"
 */
session_start();
//if( isset($_SESSION['last_key']) ) header("Location: weibolist.php");
include_once 'config.php';
include_once 'weibooauth.php';
$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
$keys = $o->getRequestToken();
$_SESSION['keys'] = $keys;
$callback_prefix = 'http://' . $_SERVER['HTTP_HOST'];
$callback_self = $_SERVER['PHP_SELF'];
$callback = $callback_prefix . str_replace("test.php", "test_callback.php", $callback_self);
$aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $callback);
?>

<a href="<?php 
echo $aurl;
?>
">Use Oauth to login</a>
예제 #15
0
 public function public_sina_login()
 {
     define('WB_AKEY', pc_base::load_config('system', 'sina_akey'));
     define('WB_SKEY', pc_base::load_config('system', 'sina_skey'));
     pc_base::load_app_class('weibooauth', '', 0);
     $this->_session_start();
     if (isset($_GET['callback']) && trim($_GET['callback'])) {
         $o = new WeiboOAuth(WB_AKEY, WB_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
         $_SESSION['last_key'] = $o->getAccessToken($_REQUEST['oauth_verifier']);
         $c = new WeiboClient(WB_AKEY, WB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
         //获取用户信息
         $me = $c->verify_credentials();
         if (CHARSET != 'utf-8') {
             $me['name'] = iconv('utf-8', CHARSET, $me['name']);
             $me['location'] = iconv('utf-8', CHARSET, $me['location']);
             $me['description'] = iconv('utf-8', CHARSET, $me['description']);
             $me['screen_name'] = iconv('utf-8', CHARSET, $me['screen_name']);
         }
         if (!empty($me['id'])) {
             $this->_init_phpsso();
             $status = $this->client->ps_get_member_info('sina_' . $me['id'], 2);
             //如果sso中有用户
             if ($status != '-1') {
                 $memberinfo = unserialize($status);
                 //接口返回序列化,进行判断
             } else {
                 //sso中无此用户,注册用户
                 $status = $this->client->ps_member_register('sina_' . $me['id'], md5($me['id']), $me['id'] . '@sina.com', ip());
                 if ($status > 0) {
                     $memberinfo['uid'] = $status;
                     $info['phpssouid'] = $status;
                     //取phpsso密码随机数
                     $info['username'] = '******' . $me['id'];
                     $info['password'] = md5($me['id']);
                     $info['email'] = '';
                     $info['nickname'] = $me['name'];
                     $info['modelid'] = 10;
                     $info['regip'] = ip();
                     $info['groupid'] = $this->_get_usergroup_bypoint();
                     $info['regdate'] = $info['lastdate'] = SYS_TIME;
                     $this->db->insert($info);
                 }
             }
             if (isset($memberinfo['uid']) && is_numeric($memberinfo['uid'])) {
                 //查询帐号信息
                 $r = $this->db->get_one(array('phpssouid' => $memberinfo['uid']));
                 $password = $r['password'];
                 $synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
                 $userid = $r['userid'];
                 $groupid = $r['groupid'];
                 $username = $r['username'];
                 $nickname = empty($r['nickname']) ? $username : $r['nickname'];
                 $this->db->update(array('lastip' => ip(), 'lastdate' => SYS_TIME, 'nickname' => $me['name']), array('userid' => $userid));
                 if (!$cookietime) {
                     $get_cookietime = param::get_cookie('cookietime');
                 }
                 $_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
                 $cookietime = $_cookietime ? TIME + $_cookietime : 0;
                 $phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key') . $this->http_user_agent);
                 $phpcms_auth = sys_auth($userid . "\t" . $password, 'ENCODE', $phpcms_auth_key);
                 param::set_cookie('auth', $phpcms_auth, $cookietime);
                 param::set_cookie('_userid', $userid, $cookietime);
                 param::set_cookie('_username', $username, $cookietime);
                 param::set_cookie('_groupid', $groupid, $cookietime);
                 param::set_cookie('cookietime', $_cookietime, $cookietime);
                 param::set_cookie('_nickname', $nickname, $cookietime);
                 $forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
                 if (!empty($forward)) {
                     //header('Location: '.$forward);
                 } else {
                     //header('Location: http://'.SITE_URL.'index.php?m=member&c=index');
                 }
                 showmessage(L('login_success') . $synloginstr, 'index.php?m=member&c=index&a=init');
             }
         } else {
             showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
         }
     } else {
         $o = new WeiboOAuth(WB_AKEY, WB_SKEY);
         $keys = $o->getRequestToken();
         $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, APP_PATH . 'index.php?m=member&c=index&a=public_sina_login&callback=1');
         $_SESSION['keys'] = $keys;
         include template('member', 'connect_sina');
     }
 }
 public function sina_sender()
 {
     //die();
     $t2 = $this->get_sina_ioco();
     $_SESSION['app_key'] = $t2['app_key'];
     $_SESSION['app_secret'] = $t2['app_secret'];
     $o = new WeiboOAuth($t2['app_key'], $t2['app_secret']);
     $keys = $o->getRequestToken();
     if (!isset($keys['oauth_token'])) {
         $keys = $o->getRequestToken();
     }
     $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, 'http://' . $_SERVER['HTTP_HOST'] . '/admin/weibo_rbs/opscallback');
     $_SESSION['keys'] = $keys;
     $this->redirect($aurl);
 }
예제 #17
0
파일: index.php 프로젝트: robertniu/php
<?php

session_start();
//if( isset($_SESSION['last_key']) ) header("Location: weibolist.php");
include_once 'config.php';
include_once 'weibooauth.php';
$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
echo "index-bp-1<br>";
$keys = $o->getRequestToken();
echo "index-bp-2<br>";
$aurl = $o->getAuthorizeURL($keys['oauth_token'], false, 'http://pengpeng.sinaapp.com/callback.php');
echo "index-bp-3<br>";
echo "<a href=" . $aurl . ">Use Oauth to login</a><br>";
$_SESSION['keys'] = $keys;
?>

<!--
<a href="<?php 
echo $aurl;
?>
">Use Oauth to login</a>
-->
예제 #18
0
 function page()
 {
     $type = $_GET['t'] ? $_GET['t'] : 'sina';
     $action = $_REQUEST['act'];
     $user = Action::$login_user;
     $weibo = D('weibobind');
     $bind = $weibo->where("uid='{$user['user_id']}'")->find();
     if ($action == 'sinasave') {
         $sinatb = intval($_POST['sinatb']);
         $weibo->where("uid='{$user['user_id']}'")->setField('sendtosina', $sinatb);
         Cookie::set('setok', '新浪帐号设置成功');
         header('location: ' . SITE_URL . '/p/weibologin?t=sina');
         exit;
     }
     if ($action == 'qqsave') {
         $qqtb = intval($_POST['qqtb']);
         $weibo->where("uid='{$user['user_id']}'")->setField('sendtoqq', $qqtb);
         Cookie::set('setok', '腾讯帐号设置成功');
         header('location: ' . SITE_URL . '/p/weibologin?t=qq');
         exit;
     }
     if ($action == 'unbindsina') {
         $weibo->where("uid='{$user['user_id']}'")->setField(array('sina_uid', 'sina_token', 'sina_tsecret', 'sendtosina'), '0');
         Cookie::set('setok', '新浪帐号解绑成功');
         header('location: ' . SITE_URL . '/p/weibologin?t=sina');
         exit;
     }
     if ($action == 'unbindqq') {
         $weibo->where("uid='{$user['user_id']}'")->setField(array('qq_uid', 'qq_token', 'qq_tsecret', 'sendtoqq'), '0');
         Cookie::set('setok', '腾讯帐号解绑成功');
         header('location: ' . SITE_URL . '/p/weibologin?t=qq');
         exit;
     }
     if ($action == 'bindsina') {
         if (!$bind['sina_uid']) {
             $sinawb = new WeiboOAuth(WB_AKEY, WB_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
             $last_key = $sinawb->getAccessToken($_REQUEST['oauth_verifier']);
             if ($last_key['oauth_token']) {
                 $canbind = $weibo->where("sina_uid='{$last_key['user_id']}'")->find();
                 if ($canbind) {
                     Cookie::set('setok', '很抱歉,该新浪帐号已经被其他帐号绑定');
                     header('location: ' . SITE_URL . '/p/weibologin?t=sina');
                     exit;
                 }
                 if ($bind) {
                     $weibo->where("uid='{$user['user_id']}'")->setField(array('sina_uid', 'sina_token', 'sina_tsecret'), array($last_key['user_id'], $last_key['oauth_token'], $last_key['oauth_token_secret']));
                 } else {
                     $insert['uid'] = $user['user_id'];
                     $insert['sina_uid'] = $last_key['user_id'];
                     $insert['sina_token'] = $last_key['oauth_token'];
                     $insert['sina_tsecret'] = $last_key['oauth_token_secret'];
                     $weibo->add($insert);
                 }
                 Cookie::set('setok', '新浪帐号绑定成功');
             } else {
                 Cookie::set('setok', '新浪帐号绑定失败');
             }
         }
         header('location: ' . SITE_URL . '/p/weibologin?t=sina');
         exit;
     }
     if ($action == 'bindqq') {
         if (!$bind['qq_uid']) {
             $qqwb = new MBOpenTOAuth(MB_AKEY, MB_SKEY, $_SESSION['qqkeys']['oauth_token'], $_SESSION['qqkeys']['oauth_token_secret']);
             $last_key = $qqwb->getAccessToken($_REQUEST['oauth_verifier']);
             if ($last_key['oauth_token']) {
                 $canbind = $weibo->where("qq_uid='{$last_key['name']}'")->find();
                 if ($canbind) {
                     Cookie::set('setok', '很抱歉,该腾讯帐号已经被其他帐号绑定');
                     header('location: ' . SITE_URL . '/p/weibologin?t=qq');
                     exit;
                 }
                 if ($bind) {
                     $weibo->where("uid='{$user['user_id']}'")->setField(array('qq_uid', 'qq_token', 'qq_tsecret'), array($last_key['name'], $last_key['oauth_token'], $last_key['oauth_token_secret']));
                 } else {
                     $insert['uid'] = $user['user_id'];
                     $insert['qq_uid'] = $last_key['name'];
                     $insert['qq_token'] = $last_key['oauth_token'];
                     $insert['qq_tsecret'] = $last_key['oauth_token_secret'];
                     $weibo->add($insert);
                 }
                 Cookie::set('setok', '腾讯帐号绑定成功');
             } else {
                 Cookie::set('setok', '腾讯帐号绑定失败');
             }
         }
         header('location: ' . SITE_URL . '/p/weibologin?t=qq');
         exit;
     }
     $result .= '<div class="friends" style="height:400px">';
     if ($type == 'sina') {
         $result .= '<div class="indexh"><div class="tabon"><a href="' . SITE_URL . '/p/weibologin?t=sina">新浪帐号</a></div><div class="taboff"><a href="' . SITE_URL . '/p/weibologin?t=qq">腾讯帐号</a></div></div>';
     } else {
         $result .= '<div class="indexh"><div class="taboff"><a href="' . SITE_URL . '/p/weibologin?t=sina">新浪帐号</a></div><div class="tabon"><a href="' . SITE_URL . '/p/weibologin?t=qq">腾讯帐号</a></div></div>';
     }
     $result .= '<div style="ine-height:200%;padding:0 10px;">';
     if ($type == 'sina') {
         if ($bind['sina_uid']) {
             $result .= '<div style="float:right"><img src="' . ET_URL . '/Plugin/weibologin/images/sinalogo.jpg"></div><div class="clearline"></div>
             <form action="' . SITE_URL . '/p/weibologin" method="post">
             <table style="margin:10px 0 0 10px;font-size:12px;text-indent:10px" width="100%">
             <tr height="60px">
             <td width="150px" bgcolor="#f3f3f3">绑定新浪微博帐号:</td>
             <td bgcolor="#ffffde">' . $bind['sina_uid'] . '</td>';
             $result .= '</tr><tr height="60px"><td bgcolor="#f3f3f3">是否同步发表微博:</td>';
             if ($bind['sendtosina']) {
                 $result .= '<td bgcolor="#ffffde"><input type="radio" name="sinatb" value="1" checked> 是&nbsp;&nbsp;&nbsp; <input type="radio" name="sinatb" value="0"> 否</td>';
             } else {
                 $result .= '<td bgcolor="#ffffde"><input type="radio" name="sinatb" value="1"> 是&nbsp;&nbsp;&nbsp; <input type="radio" name="sinatb" value="0" checked> 否</td>';
             }
             $result .= '</tr>
             <tr height="120px">
                 <td> </td>
                 <td><input type="hidden" name="act" value="sinasave">
                 <input type="submit" class="button1" value="提交保存">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                 <input type="button" class="button3" value="解绑帐号" onclick="if(confirm(\'是否确定要解绑新浪微博帐号?\')){window.location.href=\'' . SITE_URL . '/p/weibologin?act=unbindsina\'}">
                 </td>
             </tr>
             </table>
             </from>';
         } else {
             session_start();
             unset($_SESSION['keys']);
             $sinawb = new WeiboOAuth(WB_AKEY, WB_SKEY);
             $keys = $sinawb->getRequestToken();
             $aurl = $sinawb->getAuthorizeURL($keys['oauth_token'], false, SITE_URL . '/p/weibologin?act=bindsina');
             $_SESSION['keys'] = $keys;
             $result .= '<div style="text-align:center;width:100%;margin-top:80px;font-size:14px">
             <img src="' . ET_URL . '/Plugin/weibologin/images/sinalogo.jpg"><br/><br/><a href="' . $aurl . '">您还未绑定新浪帐号,点击绑定!</a>
             </div>';
         }
     } else {
         if ($type == 'qq') {
             if ($bind['qq_uid']) {
                 $result .= '<div style="float:right"><img src="' . ET_URL . '/Plugin/weibologin/images/qqlogo.jpg"></div><div class="clearline"></div>
             <form action="' . SITE_URL . '/p/weibologin" method="post">
             <table style="margin:10px 0 0 10px;font-size:12px;text-indent:10px" width="100%">
             <tr height="60px">
             <td width="150px" bgcolor="#f3f3f3">绑定腾讯微博帐号:</td>
             <td bgcolor="#ffffde">' . $bind['qq_uid'] . '</td>';
                 $result .= '</tr><tr height="60px"><td bgcolor="#f3f3f3">是否同步发表微博:</td>';
                 if ($bind['sendtoqq']) {
                     $result .= '<td bgcolor="#ffffde"><input type="radio" name="qqtb" value="1" checked> 是&nbsp;&nbsp;&nbsp; <input type="radio" name="qqtb" value="0"> 否</td>';
                 } else {
                     $result .= '<td bgcolor="#ffffde"><input type="radio" name="qqtb" value="1"> 是&nbsp;&nbsp;&nbsp; <input type="radio" name="qqtb" value="0" checked> 否</td>';
                 }
                 $result .= '</tr>
             <tr height="120px">
                 <td> </td>
                 <td><input type="hidden" name="act" value="qqsave">
                 <input type="submit" class="button1" value="提交保存">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                 <input type="button" class="button3" value="解绑帐号" onclick="if(confirm(\'是否确定要解绑腾讯微博帐号?\')){window.location.href=\'' . SITE_URL . '/p/weibologin?act=unbindqq\'}">
                 </td>
             </tr>
             </table>
             </from>';
             } else {
                 session_start();
                 unset($_SESSION['qqkeys']);
                 $qqwb = new MBOpenTOAuth(MB_AKEY, MB_SKEY);
                 $keys = $qqwb->getRequestToken(SITE_URL . '/p/weibologin?act=bindqq');
                 $aurl = $qqwb->getAuthorizeURL($keys['oauth_token'], false, '');
                 $_SESSION['qqkeys'] = $keys;
                 $result .= '<div style="text-align:center;width:100%;margin-top:80px;font-size:14px">
             <img src="' . ET_URL . '/Plugin/weibologin/images/qqlogo.jpg"><br/><br/><a href="' . $aurl . '">您还未绑定腾讯帐号,点击绑定!</a>
             </div>';
             }
         }
     }
     $result .= '</div></div>';
     return $result;
 }
예제 #19
0
파일: index.php 프로젝트: hxzyzz/ddc
	public function public_sina_login() {
		define('WB_AKEY', pc_base::load_config('system', 'sina_akey'));
		define('WB_SKEY', pc_base::load_config('system', 'sina_skey'));
		pc_base::load_app_class('weibooauth', '' ,0);
		$this->_session_start();
					
		if(isset($_GET['callback']) && trim($_GET['callback'])) {
			$o = new WeiboOAuth(WB_AKEY, WB_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
			$_SESSION['last_key'] = $o->getAccessToken($_REQUEST['oauth_verifier']);
			$c = new WeiboClient(WB_AKEY, WB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
			//获取用户信息
			$me = $c->verify_credentials();
			if(CHARSET != 'utf-8') {
				$me['name'] = iconv('utf-8', CHARSET, $me['name']);
				$me['location'] = iconv('utf-8', CHARSET, $me['location']);
				$me['description'] = iconv('utf-8', CHARSET, $me['description']);
				$me['screen_name'] = iconv('utf-8', CHARSET, $me['screen_name']);
			}
			if(!empty($me['id'])) {
				//检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
				$where = array('connectid'=>$me['id'], 'from'=>'sina');
				$r = $this->db->get_one($where);
				
				//connect用户已经绑定本站用户
				if(!empty($r)) {
					//读取本站用户信息,执行登录操作
					$password = $r['password'];
					$this->_init_phpsso();
					$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
					$userid = $r['userid'];
					$groupid = $r['groupid'];
					$username = $r['username'];
					$nickname = empty($r['nickname']) ? $username : $r['nickname'];
					$this->db->update(array('lastip'=>ip(), 'lastdate'=>SYS_TIME, 'nickname'=>$me['name']), array('userid'=>$userid));
					
					if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
					$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
					$cookietime = $_cookietime ? TIME + $_cookietime : 0;
					
					$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
					$phpcms_auth = sys_auth($userid."\t".$password, 'ENCODE', $phpcms_auth_key);
					
					param::set_cookie('auth', $phpcms_auth, $cookietime);
					param::set_cookie('_userid', $userid, $cookietime);
					param::set_cookie('_username', $username, $cookietime);
					param::set_cookie('_groupid', $groupid, $cookietime);
					param::set_cookie('cookietime', $_cookietime, $cookietime);
					param::set_cookie('_nickname', $nickname, $cookietime);
					$forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
					showmessage(L('login_success').$synloginstr, $forward);
					
				} else {				
					//弹出绑定注册页面
					$_SESSION['connectid'] = $me['id'];
					$_SESSION['from'] = 'sina';
					$connect_username = $me['name'];
					include template('member', 'connect');
				}
			} else {
				showmessage(L('login_failure'), 'index.php?m=member&c=index&a=login');
			}
		} else {
			$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
			$keys = $o->getRequestToken();
			$aurl = $o->getAuthorizeURL($keys['oauth_token'] ,false , APP_PATH.'index.php?m=member&c=index&a=public_sina_login&callback=1');
			$_SESSION['keys'] = $keys;
			include template('member', 'connect_sina');
		}
	}
예제 #20
0
<?php

session_start();
//if( isset($_SESSION['last_key']) ) header("Location: weibolist.php");
include_once 'config.php';
include_once 'weibooauth.php';
$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
$keys = $o->getRequestToken();
$aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $_SERVER['SCRIPT_URI'] . '/callback.php');
$_SESSION['keys'] = $keys;
?>
<a href="<?php 
echo $aurl;
?>
">Use Oauth to login</a>
예제 #21
0
파일: index.php 프로젝트: momoim/momo-api
<?php

session_start();
//if( isset($_SESSION['last_key']) ) header("Location: weibolist.php");
include_once 'config.php';
include_once 'weibooauth.php';
$url = sprintf('%s://%s%s', !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
$o = new WeiboOAuth(WB_AKEY, WB_SKEY);
$keys = $o->getRequestToken();
$aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $url . 'callback.php');
$_SESSION['keys'] = $keys;
header("Content-type: text/html; charset=utf-8");
?>
<a href="<?php 
echo $aurl;
?>
">使用oauth登陆</a>