当前位置: 首页>>代码示例>>PHP>>正文


PHP OAuth::getConf方法代码示例

本文整理汇总了PHP中OAuth::getConf方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuth::getConf方法的具体用法?PHP OAuth::getConf怎么用?PHP OAuth::getConf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuth的用法示例。


在下文中一共展示了OAuth::getConf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     require_once Yii::getPathOfAlias('ext') . "/OAuth/sinawb/saetv2.ex.class.php";
     $config = OAuth::getConf('sinawb');
     $sinawb = new SaeTOAuthV2($config['wb_akey'], $config['wb_skey']);
     $code_url = $sinawb->getAuthorizeURL($config['callback']);
     $this->controller->redirect($code_url);
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:8,代码来源:SinawbAction.php

示例2: run

 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);
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:12,代码来源:RenrenAction.php

示例3: run

 public function run()
 {
     require_once Yii::getPathOfAlias('ext') . "/OAuth/weixin/weixin.class.php";
     Yii::import('application.extensions.qrcode.QrCode');
     $config = OAuth::getConf('weixin');
     $random_uuid = $this->_createUUid();
     $wx = new WeiXin($config['app_id'], $config['app_secret'], $config['callback'], $random_uuid);
     $qr = new QrCode();
     $qrcode_url = $qr->createCode($wx->auth_url, 8);
     $this->controller->layout = false;
     $this->controller->_seoTitle = '微信扫一扫登录' . ' - ' . $this->controller->_setting['site_name'];
     $this->controller->render('wx_qrcode', array('qrcode_url' => $qrcode_url));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:13,代码来源:WeixinAction.php

示例4: run

 public function run()
 {
     require_once Yii::getPathOfAlias('ext') . "/OAuth/renren/rennclient/RennClient.php";
     $config = OAuth::getConf('renren');
     $rennClient = new RennClient($config['app_key'], $config['app_secret']);
     // 处理code -- 根据code来获得token
     if (isset($_REQUEST['code'])) {
         // 验证state,防止伪造请求跨站攻击
         $state = $_REQUEST['state'];
         if (empty($state) || $state !== Yii::app()->session['renren_state']) {
             throw new CHttpException(500, 'Error: Illegal Request');
         }
         unset(Yii::app()->session['renren_state']);
         // 获得code
         $code = $_REQUEST['code'];
         $redirect_uri = $config['callback'];
         try {
             // 根据code来获得token
             $token = $rennClient->authWithAuthorizationCode($code, $redirect_uri);
         } catch (RennException $e) {
             throw new CHttpException(500, 'Error:' . $e->getMessage());
         }
     } else {
         throw new CHttpException(500, 'Auth Failed');
     }
     if ($token) {
         // 获得保存的token
         $rennClient->authWithStoredToken();
         // 获得用户接口
         $user_service = $rennClient->getUserService();
         // 获得用户信息
         $user = $user_service->getUser(null);
         if (!$user) {
             throw new CHttpException('500', Yii::t('common', 'Login Failed') . '(get userinfo failed)');
         }
         // 获取accessToken
         $access_token = $token->accessToken;
         $openid = $user['id'];
         //查看是否已绑定
         $bind = OAuthRenren::model()->findByPk($openid);
         //数据
         $data = array('type' => 'renren', 'access_token' => $access_token, 'openid' => $openid, 'uid' => $bind ? $bind->uid : 0, 'username' => $user['name'], 'avatar' => $user['avatar'][1]['url']);
         //绑定注册
         $this->controller->bind_register($bind, $data);
     } else {
         $this->controller->message('error', Yii::t('common', 'Login Failed') . '(renren_x_0000)', $this->createUrl('user/login'));
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:48,代码来源:RenrenCallBackAction.php

示例5: run

 public function run()
 {
     require_once Yii::getPathOfAlias('ext') . "/OAuth/sinawb/saetv2.ex.class.php";
     $config = OAuth::getConf('sinawb');
     $sinawb = new SaeTOAuthV2($config['wb_akey'], $config['wb_skey']);
     if (isset($_REQUEST['code'])) {
         $keys = array();
         $keys['code'] = $_REQUEST['code'];
         $keys['redirect_uri'] = $config['callback'];
         try {
             $token = $sinawb->getAccessToken('code', $keys);
         } catch (OAuthException $e) {
             throw new CHttpException(500, 'Error:' . $e->getMessage());
         }
     }
     if ($token) {
         $access_token = Yii::app()->session['access_token'] = $token['access_token'];
         $openid = $token['uid'];
         //设置cookie
         $cookie_name = 'weibojs_' . $openid;
         $cookie = new CHttpCookie($cookie_name, http_build_query($token));
         $cookie->expire = time() + 60 * 60 * 24 * 30;
         //有限期30天
         Yii::app()->request->cookies[$cookie_name] = $cookie;
         //获取用户信息
         $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $access_token);
         $user_info = $c->show_user_by_id($openid);
         //根据ID获取用户等基本信息
         if ($user_info['error']) {
             throw new CHttpException('500', Yii::t('common', 'Login Failed') . '(' . $user_info['error_code'] . ')');
         }
         //查看是否已绑定
         $bind = OAuthSinawb::model()->findByPk($openid);
         //数据
         $data = array('type' => 'sinawb', 'access_token' => $access_token, 'openid' => $openid, 'uid' => $bind ? $bind->uid : 0, 'username' => $user_info['screen_name'], 'avatar' => $user_info['avatar_large']);
         //绑定注册
         $this->controller->bind_register($bind, $data);
     } else {
         $this->controller->message('error', Yii::t('common', 'Login Failed') . '(sinawb_x_0000)', $this->createUrl('user/login'));
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:41,代码来源:SinawbCallBackAction.php


注:本文中的OAuth::getConf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。