getAuthorizeURL() public method

对应API:{@link http://open.weibo.com/wiki/Oauth2/authorize Oauth2/authorize}
public getAuthorizeURL ( string $url, string $response_type = 'code', string $state = NULL, string $display = NULL ) : array
$url string 授权后的回调地址,站外应用需与回调地址一致,站内应用需要填写canvas page的地址
$response_type string 支持的值包括 code 和token 默认值为code
$state string 用于保持请求和回调的状态。在回调时,会在Query Parameter中回传该参数
$display string 授权页面类型 可选范围: - default 默认授权页面 - mobile 支持html5的手机 - popup 弹窗授权页 - wap1.2 wap1.2页面 - wap2.0 wap2.0页面 - js js-sdk 专用 授权页面是弹窗,返回结果为js-sdk回掉函数 - apponweibo 站内应用专用,站内应用不传display参数,并且response_type为token时,默认使用改display.授权后不会返回access_token,只是输出js刷新站内应用父框架
return array
Esempio n. 1
0
 private function reflashToken()
 {
     if (empty($this->m_cfg['username']) || empty($this->m_cfg['password'])) {
         return;
     }
     $this->m_reflash_cookie = tmpDir('reflashsina.cookie');
     if (!file_exists($this->m_reflash_cookie)) {
         touch($this->m_reflash_cookie);
     }
     $loginResult = $this->curlLoginSina($this->m_cfg['username'], $this->m_cfg['password']);
     if (!$loginResult) {
         return $loginResult;
     }
     $callbackUrl = callbackUrl('sina');
     $o = new SaeTOAuthV2($this->m_cfg['key'], $this->m_cfg['secret']);
     $authorizeURL = $o->getAuthorizeURL($callbackUrl);
     $ch = curl_init($authorizeURL);
     $option = array();
     $option[CURLOPT_FOLLOWLOCATION] = 1;
     $option[CURLOPT_RETURNTRANSFER] = 1;
     $option[CURLOPT_COOKIEJAR] = $this->m_reflash_cookie;
     $option[CURLOPT_COOKIEFILE] = $this->m_reflash_cookie;
     $option[CURLOPT_HTTPHEADER] = array('Accept-Language: zh-cn', 'Connection: Keep-Alive', 'Cache-Control: no-cache');
     $option[CURLOPT_USERAGENT] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
     curl_setopt_array($ch, $option);
     curl_exec($ch);
     curl_close($ch);
     unlink($this->m_reflash_cookie);
 }
Esempio n. 2
0
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * 		http://example.com/index.php/welcome
  * 	- or -  
  * 		http://example.com/index.php/welcome/index
  * 	- or -
  * Since this controller is set as the default controller in 
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
     $data['code_url'] = $code_url;
     $this->load->view('celebritytop/navigate_view', $data);
 }
Esempio n. 3
0
 public function index()
 {
     if (!$this->customer->isLogged()) {
         $appkey = $this->config->get('weibo_login_appkey');
         $appsecret = $this->config->get('weibo_login_appsecret');
         $callback_url = $this->url->link('extension/module/weibo_login/callback', '', true);
         $this->load->language('extension/module/weibo_login');
         $data['text_weibo_login'] = $this->language->get('text_weibo_login');
         include_once DIR_SYSTEM . 'library/weibo/saetv2.ex.class.php';
         $o = new SaeTOAuthV2($appkey, $appsecret);
         $data['code_url'] = $o->getAuthorizeURL($callback_url);
         if ($this->customer->isLogged()) {
             $data['logged'] = 1;
         } else {
             $data['logged'] = 0;
         }
         if (isset($this->session->data['weibo_login_access_token']) && isset($this->session->data['weibo_login_uid'])) {
             $data['weibo_login_authorized'] = 1;
         } else {
             $data['weibo_login_authorized'] = 0;
             unset($this->session->data['weibo_login_access_token']);
             unset($this->session->data['weibo_login_uid']);
         }
         $this->load->helper('mobile');
         if (is_weixin()) {
             $data['is_weixin'] = 1;
         } else {
             $data['is_weixin'] = 0;
         }
         return $this->load->view('extension/module/weibo_login', $data);
     }
 }
Esempio n. 4
0
 function getLoginUrl()
 {
     require_once dirname(__FILE__) . "/API/saetv2.ex.class.php";
     $o = new SaeTOAuthV2(ISession::get('apiKey'), ISession::get('apiSecret'));
     $code_url = $o->getAuthorizeURL(parent::getReturnUrl());
     return $code_url;
 }
 function logs()
 {
     import("Org.Util.saetv2");
     $o = new \SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
     return $code_url;
 }
Esempio n. 6
0
 public function index()
 {
     if (isset($this->request->get['message_id']) && $this->request->get['message_id']) {
         if (isset($this->request->get['message_id'])) {
             $message_id = $this->request->get['message_id'];
         } else {
             $message_id = '';
         }
         //判断用户是否登陆
         if ($this->customer->isLogged()) {
             $this->data['logged'] = 1;
         } else {
             $this->data['logged'] = 0;
             $this->data['error_login'] = "";
             $this->data['action'] = $this->url->link('account/login', '', 'SSL');
             $this->data['register'] = $this->url->link('account/register', '', 'SSL');
             $this->data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');
             $this->data['email'] = '';
             $this->data['password'] = '';
             include_once DIR_SYSTEM . 'weibo/config.php';
             include_once DIR_SYSTEM . 'weibo/saetv2.ex.class.php';
             $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
             $this->data['code_url'] = $o->getAuthorizeURL(WB_CALLBACK_URL);
         }
         $this->load->model('social/social');
         $message_info = $this->model_social_social->getMessageByid($message_id);
         if (isset($this->request->get['page'])) {
             $page = $this->request->get['page'];
             $this->data['page'] = $page;
         } else {
             $page = 1;
             $this->data['page'] = $page;
         }
         $limit = 20;
         $this->data['limit'] = $limit;
         $data = array('message_id' => $message_id, 'start' => ($page - 1) * $limit, 'limit' => $limit);
         $comment_info = $this->model_social_social->getComment($data);
         $comment_total = $this->model_social_social->getTotalComment($message_id);
         //回复的用户id
         $this->data['customer_id'] = $this->customer->getId();
         //回复的脸
         $this->data['face'] = $this->customer->getface();
         if (!$this->data['face']) {
             $this->data['face'] = "uploads/big/0b4a96400b2372d25da769647bfe4059.jpg";
         }
         $this->data['message'] = $message_info;
         $this->data['comment_info_all'] = $comment_info;
         $this->data['comment_total'] = $comment_total;
         $pagination = new Pagination();
         $pagination->total = $comment_total;
         $pagination->page = $page;
         $pagination->limit = $limit;
         $pagination->text = $this->language->get('text_pagination');
         $pagination->url = $this->url->link('social/comment', 'message_id=' . $message_id . '&page={page}', 'SSL');
         $this->data['pagination'] = $pagination->render();
         $this->template = $this->config->get('config_template') . '/template/social/comment_list.tpl';
         $this->children = array('common/footer', 'common/social_right', 'common/header_sns');
         $this->response->setOutput($this->render());
     }
 }
Esempio n. 7
0
 public function actionIndex()
 {
     $o = new \SaeTOAuthV2($this->app_key, $this->app_secret);
     $code_url = $o->getAuthorizeURL($this->url);
     header("location:{$code_url}");
     exit;
 }
Esempio n. 8
0
 /**
  *微博登陆
  *@author winter
  *@version 2015年11月20日17:27:32
  */
 public function weibologin()
 {
     include_once './libweibo/config.php';
     include_once './libweibo/saetv2.ex.class.php';
     $o = new \SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
     header("Location:" . $code_url);
 }
 /**
  * sinaLogin
  */
 public function sinaLogin()
 {
     $state = md5(rand(5, 10));
     Yii::app()->session->add('sina_state', $state);
     $weiboService = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $this->sina_code_url = $weiboService->getAuthorizeURL(WB_CALLBACK_URL, 'code', $state);
     Yii::app()->session->add('back_url', $this->back_url . '?state=' . $state);
 }
Esempio n. 10
0
 /**
  * 新浪微博授权登录
  * sinawb login
  */
 public function actionSinawb()
 {
     require_once Yii::getPathOfAlias('ext') . "/OAuth/sinawb/config.php";
     require_once Yii::getPathOfAlias('ext') . "/OAuth/sinawb/saetv2.ex.class.php";
     $sinawb = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $code_url = $sinawb->getAuthorizeURL(WB_CALLBACK_URL);
     $this->redirect($code_url);
 }
Esempio n. 11
0
 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);
 }
Esempio n. 12
0
 /**
  *  是否已经获取到了token,未获取则显示获取token的图标,否则显示当前登录账号
  *
  * @access public
  * @param 
  * @return string
  */
 public static function SinaAuth()
 {
     self::getPubFile();
     $sina_auth = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $authurl = $sina_auth->getAuthorizeURL(WB_CALLBACK_URL, 'code');
     $img_path = Helper::options()->pluginUrl . '/WeiboSync/weibo.png';
     echo $sina_profile = '<ul class="typecho-option"><li><a href="' . $authurl . '"><img src="' . $img_path . '"></a>&nbsp;&nbsp;<b>点击左边图标获取微博Access_token信息</b></li></ul>';
 }
Esempio n. 13
0
 public function weibo()
 {
     Vendor('Weibo.saetv2#ex#class');
     $o = new \SaeTOAuthV2(C('weibo.wb_akey'), C('weibo.wb_skey'));
     $code_url = $o->getAuthorizeURL(C('weibo.wb_callback_url'));
     header('Location: ' . $code_url);
     exit;
 }
Esempio n. 14
0
 public function index()
 {
     import('Vendor.Weibo.saetv2');
     $weibo = new \SaeTOAuthV2(WB_APPKEY, WB_SKEY);
     $code_url = $weibo->getAuthorizeURL(WB_CALLBACK_URL);
     $this->assign('code_url', $code_url);
     $this->display();
 }
Esempio n. 15
0
 function sina_oauth()
 {
     require_once APPPATH . 'libraries/sina/saetv2.ex.class.php';
     $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $back_url = base_url() . 'index.php?c=oauth&m=sina_oauth_back';
     $data['code_url'] = $o->getAuthorizeURL($back_url);
     $this->load->view('/oauth/sina_oauth', $data);
 }
Esempio n. 16
0
/**
 * 此函数,返回一个供认证转移的URL
 */
function AuthUrlGet_sina($path)
{
    $sinaappkey = $_SESSION['sinaappkey'];
    $sinasecret = $_SESSION['sinasecret'];
    $_SESSION['wb_callback_url'] = $path;
    $o = new SaeTOAuthV2($sinaappkey, $sinasecret);
    $aurl = $o->getAuthorizeURL($path);
    return $aurl;
}
Esempio n. 17
0
 public static function getWeiboLoginUrl()
 {
     if (!self::$_config) {
         self::$_config = (require_once WEIBO_PATH . 'config/config.php');
     }
     $o = new SaeTOAuthV2(self::$_config['WB_AKEY'], self::$_config['WB_SKEY']);
     $url = $o->getAuthorizeURL(self::$_config['WB_CALLBACK_URL']);
     return $url;
 }
Esempio n. 18
0
 public function action()
 {
     //跳转
     if (!class_exists('SaeTOAuthV2')) {
         require_once './saetv2.ex.class.php';
     }
     $saeto_client = new SaeTOAuthV2($this->config->client_id, $this->config->client_secret);
     $authorize_url = $saeto_client->getAuthorizeURL($this->config->callback_url, 'code');
     $this->response->redirect($authorize_url);
     exit;
 }
Esempio n. 19
0
 /**
  * 登陆页面
  * @author Mr.Cong <*****@*****.**>
  */
 public function index()
 {
     $callback = I('callback', '', 'urlencode');
     if ($callback != false) {
         $this->Redis->set('callback', $callback, 30);
     }
     //微博登陆
     $auth = new \SaeTOAuthV2($this->weibo_akey, $this->weibo_skey);
     $weibo_login_url = $auth->getAuthorizeURL(C('WB_CALLBACK_URL'));
     header('Location:' . $weibo_login_url);
 }
Esempio n. 20
0
function oauth_login($config)
{
    if (!function_exists("curl_init")) {
        echo "<h1>新浪开放平台提示:请先开启curl支持</h1>";
        echo "\n\t\t\t开启php curl函数库的步骤(for windows)<br />\n\t\t\t1).去掉windows/php.ini 文件里;extension=php_curl.dll前面的; /*用 echo phpinfo();查看php.ini的路径*/<br />\n\t\t\t2).把php5/libeay32.dll,ssleay32.dll复制到系统目录windows/下<br />\n\t\t\t3).重启apache<br />\n\t\t\t";
        exit;
    }
    $o = new SaeTOAuthV2($config['appid'], $config['appkey']);
    $callback = get_callback_url();
    $aurl = $o->getAuthorizeURL($callback);
    header("location:" . $aurl);
}
Esempio n. 21
0
 public function sina()
 {
     $loginconfig = FS("Webconfig/loginconfig");
     define("WB_AKEY", $loginconfig['sina']['akey']);
     define("WB_SKEY", $loginconfig['sina']['skey']);
     define("WB_CALLBACK_URL", C('WEB_URL') . __APP__ . '/member/oauth/sinalogin');
     require C("APP_ROOT") . "Lib/Oauth/sina/saetv2.ex.class.php";
     //构造快捷登录接口
     $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
     redirect($code_url);
 }
Esempio n. 22
0
 /**
  * 获取AuthorizeURL
  * 用于 新浪登录 按钮
  * redirect_uri  回调的url
  */
 public static function getAuthorizeURL($paramArr)
 {
     $options = array('redirect_uri' => '');
     if (is_array($paramArr)) {
         $options = array_merge($options, $paramArr);
     }
     extract($options);
     if (!$redirect_uri) {
         return false;
     }
     $loginObj = new SaeTOAuthV2(self::$WB_AKEY, self::$WB_SKEY);
     return $loginObj->getAuthorizeURL($redirect_uri);
 }
Esempio n. 23
0
 function weibo()
 {
     session_start();
     require_once APPPATH . 'libraries/weibo/config.php';
     require_once APPPATH . 'libraries/weibo/saetv2.ex.class.php';
     $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $o->set_debug(DEBUG_MODE);
     // 生成state并存入SESSION,以供CALLBACK时验证使用
     $state = uniqid('weibo_', true);
     $_SESSION['weibo_state'] = $state;
     $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL, 'code', $state);
     redirect($code_url);
 }
 public function get_bind_api_url()
 {
     require_once APP_ROOT_PATH . 'system/api_login/sina/saetv2.ex.class.php';
     $o = new SaeTOAuthV2($this->api['config']['app_key'], $this->api['config']['app_secret']);
     es_session::start();
     //$keys = $o->getRequestToken();
     if ($this->api['config']['app_url'] == "") {
         $app_url = get_domain() . APP_ROOT . "/api_callback.php?c=Sina";
     } else {
         $app_url = $this->api['config']['app_url'];
     }
     $aurl = $o->getAuthorizeURL($app_url);
     return $aurl;
 }
Esempio n. 25
0
 function __construct($allow_debug = false)
 {
     $this->memcache = new Memcache();
     $this->memcache->connect(MC_HOST, 11211) or die("Could not connect");
     if (!$this->memcache->get(MC_KEY)) {
         $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
         $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
         if ($allow_debug) {
             echo '<a href="' . $code_url . '">' . $code_url . '</a><br /><br />';
         }
     }
     $this->c = new SaeTClientV2(WB_AKEY, WB_SKEY, $this->memcache->get(MC_KEY));
     $this->c->set_debug($allow_debug);
 }
Esempio n. 26
0
 public function index()
 {
     $temp = $this->session->userdata('access_token');
     if (empty($temp)) {
         $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
         $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
         echo "<meta http-equiv=refresh content='0; url={$code_url}'>";
         //跳转到授权页面
     } else {
         $user_info = $this->celtop_model->get_user_day();
         $data['user_info'] = $user_info;
         $this->load->view('celebritytop/homepage_view', $data);
     }
 }
Esempio n. 27
0
 public function sina()
 {
     $loginconfig = FS("Webconfig/loginconfig");
     define("WB_AKEY", $loginconfig['sina']['akey']);
     define("WB_SKEY", $loginconfig['sina']['skey']);
     define("WB_CALLBACK_URL", "http://" . $_SERVER['HTTP_HOST'] . __APP__ . '/member/oauth/sinalogin');
     require C("APP_ROOT") . "Lib/Oauth/sina/saetv2.ex.class.php";
     //构造快捷登录接口
     $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
     $http_referer = $_SERVER["HTTP_REFERER"];
     if (strpos($http_referer, "/member/common/login") === false) {
         session("url_referer", $http_referer);
     }
     redirect($code_url);
 }
Esempio n. 28
0
 public function get_bind_api_url()
 {
     require_once APP_ROOT_PATH . 'system/api_login/sina/saetv2.ex.class.php';
     $o = new SaeTOAuthV2($this->api['config']['app_key'], $this->api['config']['app_secret']);
     es_session::start();
     //$keys = $o->getRequestToken();
     if ($this->api['config']['app_url'] == "") {
         $app_url = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Sina";
     } else {
         $app_url = $this->api['config']['app_url'];
     }
     $aurl = $o->getAuthorizeURL($app_url);
     es_session::set("is_bind", 1);
     $str = "<a href='" . $aurl . "' title='" . $this->api['name'] . "'><img src='" . $this->api['bicon'] . "' alt='" . $this->api['name'] . "' /></a>&nbsp;";
     return $str;
 }
Esempio n. 29
0
 public function weibo_url()
 {
     $cfg = K::$system->config->get('connect');
     if (defined('IN_MOBILE')) {
         $mobile = K::$system->config->get('mobile');
         $callback = $mobile['url'] . '/' . K::M('helper/link')->mklink('passport:weibocallback');
     } else {
         $site = K::$system->config->get('site');
         $callback = $site['siteurl'] . '/' . K::M('helper/link')->mklink('passport:weibocallback');
     }
     if (empty($cfg['weibo_is_open'])) {
         $this->err->add('很抱歉网站管理员还未开启微博登录功能', 201);
     } else {
         $o = new SaeTOAuthV2($cfg['weibo_app_id'], $cfg['weibo_app_key']);
         $code_url = $o->getAuthorizeURL($callback);
         return $code_url;
     }
     return false;
 }
Esempio n. 30
0
function sinaJMP__()
{
    //import ( '/library/OAuth.php' );
    //import ( '/library/sinaoauth.php' );
    import('/library/saetv2.ex.class.php');
    global $cfg_sina;
    $type = 'sina';
    $callbackUrl = callbackUrl($type);
    /*
    $o 				= new SinaOauth ($cfg_sina['key'] , $cfg_sina['secret']);
    $token 			= $o->getRequestToken ( $callbackUrl );
    $authorizeURL 	= $o->getAuthorizeURL ( $token, $callbackUrl );
    */
    $o = new SaeTOAuthV2($cfg_sina['key'], $cfg_sina['secret']);
    $authorizeURL = $o->getAuthorizeURL($callbackUrl);
    //$_SESSION ['sina_key'] = $token;
    //$o = new SaeTOAuthV2 ( $cfg_sina ['key'], $cfg_sina ['secret'] );
    //$authorizeURL = $o->getAuthorizeURL ( callbackUrl ( $type ) ,'code');
    header("Location:{$authorizeURL}");
}