Exemple #1
0
 public function run()
 {
     require_once Yii::getPathOfAlias('ext') . "/OAuth/renren/RennClient.php";
     $config = OAuth::getConf('renren');
     $rennClient = new RennClient($config['app_key'], $config['app_secret']);
     // 生成state并存入SESSION,以供CALLBACK时验证使用
     $state = uniqid('renren_', true);
     Yii::app()->session['renren_state'] = $state;
     // 取得认证授权的url
     $code_url = $rennClient->getAuthorizeURL($config['callback'], 'code', $state);
     $this->controller->redirect($code_url);
 }
 /**
  * 人人网授权登录
  * sinawb login
  */
 public function actionRenren()
 {
     require_once Yii::getPathOfAlias('ext') . "/OAuth/renren/config.php";
     require_once Yii::getPathOfAlias('ext') . "/OAuth/renren/rennclient/RennClient.php";
     $rennClient = new RennClient(APP_KEY, APP_SECRET);
     // 生成state并存入SESSION,以供CALLBACK时验证使用
     $state = uniqid('renren_', true);
     Yii::app()->session['renren_state'] = $state;
     // 得认证授权的url
     $code_url = $rennClient->getAuthorizeURL(CALLBACK_URL, 'code', $state);
     $this->redirect($code_url);
 }
Exemple #3
0
 public static function oauthRoute($type)
 {
     global $kekezu, $weibo_list;
     require S_ROOT . "include/oauth/config.php";
     if ($type === 'sina') {
         require S_ROOT . "include/oauth/sina/saetv2.ex.class.php";
         $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
         $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
     }
     if ($type === 'qq') {
         require S_ROOT . "include/oauth/qq/qqConnectAPI.php";
         $qqConnectAPI = new QC();
         $qqConnectAPI->qq_login();
         die;
     }
     if ($type === 'ten') {
         require S_ROOT . "include/oauth/ten/Tencent.php";
         OAuth::init(TEN_AKEY, TEN_SKEY);
         Tencent::$debug = false;
         $code_url = OAuth::getAuthorizeURL(TEN_CALLBACK_URL);
     }
     if ($type === 'renren') {
         require S_ROOT . "include/oauth/renren/rennclient/RennClient.php";
         $rennClient = new RennClient(APP_KEY, APP_SECRET);
         $state = uniqid('renren_', true);
         $_SESSION['renren_state'] = $state;
         $code_url = $rennClient->getAuthorizeURL(CALLBACK_URL, 'code', $state);
     }
     if ($type === 'douban') {
         require S_ROOT . 'include/oauth/douban/douban.php';
         $douBan = new doubanPHP(DB_APIKEY, DB_SECRET);
         $code_url = $douBan->login_url(DB_CALLBACK_URL, DB_SCOPE);
     }
     header("location:" . $code_url);
 }
<?php

session_start();
include_once 'config.php';
include_once '../rennclient/RennClient.php';
// include_once ('renrenoauth/oauth2-client.class.php');
// include_once ('renrenoauth/renn-client.class.php');
$rennClient = new RennClient(APP_KEY, APP_SECRET);
$rennClient->setDebug(DEBUG_MODE);
// 生成state并存入SESSION,以供CALLBACK时验证使用
$state = uniqid('renren_', true);
$_SESSION['renren_state'] = $state;
// 得认证授权的url
$code_url = $rennClient->getAuthorizeURL(CALLBACK_URL, 'code', $state);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>人人 PHP SDK Demo</title>
</head>

<body>
	<!-- 打开认证授权的页面 -->
	<p>
		<a href="<?php 
echo $code_url;
?>
"><img
			src="http://s.xnimg.cn/imgpro/v6/logo.png?f=home" title="点击进入授权页面"
			alt="点击进入授权页面" border="0" /></a>