Ejemplo n.º 1
0
/**
 * 此函数,返回一个供认证转移的URL
 */
function AuthUrlGet_tencent($path)
{
    $o = new MBOpenTOAuth(MB_AKEY, MB_SKEY);
    $keys = $o->getRequestToken($path);
    //这是回调的URL
    $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, '');
    $_SESSION['keys'] = $keys;
    return $aurl;
}
Ejemplo n.º 2
0
 function show()
 {
     $callback = site_url() . '/binding/tqq/callback';
     $o = new MBOpenTOAuth(MB_AKEY, MB_SKEY);
     $keys = $o->getRequestToken($callback);
     $this->session->set_userdata($keys);
     $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, '');
     redirect($aurl);
 }
Ejemplo n.º 3
0
function tencentJMP__()
{
    import('/library/OAuth.php');
    import('/library/tencentoauth.php');
    global $cfg_tencent;
    $type = 'tencent';
    $o = new MBOpenTOAuth($cfg_tencent['key'], $cfg_tencent['secret']);
    $keys = $o->getRequestToken(callbackUrl($type));
    $authorizeURL = $o->getAuthorizeURL($keys['oauth_token'], false, '');
    $_SESSION['tencent_keys'] = $keys;
    header("Location:{$authorizeURL}");
}
Ejemplo n.º 4
0
    /**
     * 这个数据显示一个页面,它自动会转入腾讯授权的页面
     */
    function showTencentAuth()
    {
        $o = new MBOpenTOAuth(MB_AKEY, MB_SKEY);
        $u =& JFactory::getURI();
        $p = $u->base();
        $keys = $o->getRequestToken($p . '/index.php?option=com_weibo&task=tencentcallback');
        //这是回调的URL
        $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, '');
        $_SESSION['keys'] = $keys;
        ?>
<script>
document.location.href="<?php 
        echo $aurl;
        ?>
"
</script>
		<?php 
    }
Ejemplo n.º 5
0
<?php

@header('Content-Type:text/html;charset=utf-8');
session_start();
require_once 'config.php';
require_once 'oauth.php';
require_once 'opent.php';
$o = new MBOpenTOAuth(MB_AKEY, MB_SKEY);
$keys = $o->getRequestToken('http://pg.app.yiyiee.com/callback.php');
//这里填上你的回调URL
$aurl = $o->getAuthorizeURL($keys['oauth_token'], false, '');
$_SESSION['keys'] = $keys;
?>
<a href="<?php 
echo $aurl;
?>
">用OAUTH授权登录</a>
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
0
     /*$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;
     echo '</span>';
     //
     require_once './template/setting.php';
     break;
 case 'login':