예제 #1
0
 public function getUrl($call_back = null)
 {
     if (empty($this->_douban_key) || empty($this->_douban_secret)) {
         return false;
     }
     if (is_null($call_back)) {
         $call_back = Addons::createAddonShow('Login', 'no_register_display', array('type' => 'douban', 'do' => "bind"));
     }
     if (empty($this->_authorize_url)) {
         $client = new DoubanOAuth($this->_douban_key, $this->_douban_secret);
         $request_token = $client->getRequestToken();
         $this->_authorize_url = $client->getAuthorizeURL($request_token) . '&oauth_callback=' . urlencode($call_back);
     }
     $_SESSION['douban']['request_token'] = $request_token;
     return $this->_authorize_url;
 }
예제 #2
0
 public function getUrl($call_back = null)
 {
     if (empty($this->_douban_key) || empty($this->_douban_secret)) {
         return false;
     }
     if (is_null($call_back)) {
         $call_back = U('home/Public/doubanCallback');
     }
     if (empty($this->_authorize_url)) {
         $client = new DoubanOAuth($this->_douban_key, $this->_douban_secret);
         $request_token = $client->getRequestToken();
         $this->_authorize_url = $client->getAuthorizeURL($request_token) . '&oauth_callback=' . urlencode($call_back);
     }
     $_SESSION['douban']['request_token'] = $request_token;
     return $this->_authorize_url;
 }
예제 #3
0
<?php

include "init.php";
//ROOT_URL./api.php?app=begin & account=douban
switch ($_GET['app']) {
    case "begin":
        $douban = new DoubanOAuth($douban_consumer_key, $douban_consumer_secret);
        $tok = $douban->getRequestToken();
        $url = $douban->getAuthorizeURL($tok['oauth_token']) . "&oauth_callback=";
        //$url .= $_SEVERAL[PHP_SELF]."?request_token=".$tok['oauth_token']."&request_token_secret=".$tok['oauth_token_secret'];
        $arr = array_merge($tok, array("url" => $url));
        $out = json_encode($arr);
        echo $out;
        break;
    case "access":
        $tok = $_GET["request_token"];
        $tok_s = $_GET["request_token_secret"];
        $douban = new DoubanOAuth($douban_consumer_key, $douban_consumer_secret, $tok, $tok_s);
        $access = $douban->getAccessToken();
        $out = json_encode($access);
        if (!check_user("douban", $access['douban_user_id'])) {
            add_user("douban", $access['douban_user_id']);
        }
        echo $out;
        break;
}
exit;
예제 #4
0
<?php

require 'DoubanOAuth.php';
require 'config.php';
$douban = new DoubanOAuth(array('key' => KEY, 'secret' => SECRET, 'redirect_url' => REDIRECT));
$url = $douban->getAuthorizeURL(SCOPE, STATE);
//echo '<a href="' . $url . '">使用豆瓣帐号登录</a>';
header('Location: ' . $url);
예제 #5
0
function doubanJMP__()
{
    import('/library/OAuth.php');
    import('/library/doubanoauth.php');
    $type = 'douban';
    global $cfg_douban;
    $o = new DoubanOAuth($cfg_douban['key'], $cfg_douban['secret']);
    $token = $o->getRequestToken();
    $_SESSION['douban_token'] = $token['oauth_token'];
    $_SESSION['douban_token_secret'] = $token['oauth_token_secret'];
    $authorizeURL = $o->getAuthorizeURL($token, callbackUrl($type));
    header("Location:{$authorizeURL}");
}