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


PHP OAuth::getRequestToken方法代码示例

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


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

示例1: authenticate

 /**
  * Call authorize endpoint
  */
 public function authenticate()
 {
     $this->api = new \OAuth($this->options['consumer_key'], $this->options['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     if (!$this->request->query->has('oauth_token') && $this->state === 0) {
         $request_token_info = $this->api->getRequestToken($this->options['request_token_endpoint']);
         $this->secret = $request_token_info['oauth_token_secret'];
         $this->state = 1;
         $this->redirectUrl = $this->request->getPathInfo();
         $this->saveState();
         header(sprintf('Location: %s?oauth_token=%s', $this->options['authorize_endpoint'], $request_token_info['oauth_token']));
     }
 }
开发者ID:itkg,项目名称:consumer,代码行数:15,代码来源:GuzzleOAuthAuthenticationProvider.php

示例2: call

 function call($command)
 {
     session_start();
     if (!isset($_GET['oauth_token']) && $_SESSION['state'] == 1) {
         $_SESSION['state'] = 0;
     }
     try {
         $oauth = new \OAuth($this->consumer_key, $this->consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
         $oauth->enableDebug();
         if (!isset($_GET['oauth_token']) && !$_SESSION['state']) {
             $request_token_info = $oauth->getRequestToken($this->request_url);
             $_SESSION['secret'] = $request_token_info['oauth_token_secret'];
             $_SESSION['state'] = 1;
             header('Location: ' . $this->authorize_url . '?oauth_token=' . $request_token_info['oauth_token']);
             exit;
         } else {
             if ($_SESSION['state'] == 1) {
                 $oauth->setToken($_GET['oauth_token'], $_SESSION['secret']);
                 $access_token_info = $oauth->getAccessToken($this->access_token_url);
                 error_log("acc token info " . $access_token_info, 1, "dustinmoorman@gmail.com");
                 $_SESSION['state'] = 2;
                 $_SESSION['token'] = $access_token_info['oauth_token'];
                 $_SESSION['secret'] = $access_token_info['oauth_token_secret'];
             }
         }
         $oauth->setToken($_SESSION['token'], $_SESSION['secret']);
         $oauth->fetch("{$this->api_url}{$command}");
         $json = json_decode($oauth->getLastResponse());
     } catch (\OAuthException $E) {
         return $E->lastResponse;
     }
     return $json;
 }
开发者ID:rocketcloudsolutions,项目名称:rcsoauth,代码行数:33,代码来源:Base.php

示例3: getToken

 function getToken($permissions, $callback_url)
 {
     /* Get a URL to send user to to authenticate for given permissions */
     $oauth = new OAuth($this->site_id, $this->secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     $token_info = $oauth->getRequestToken(ENTRECARD_API_URL . "/request_token?permissions=" . join(',', $permissions), urlencode($callback_url));
     return array($token_info['oauth_token'], $token_info['oauth_token_secret']);
 }
开发者ID:redspider,项目名称:Entrecard-API,代码行数:7,代码来源:oauth_entrecard.php

示例4: setOAuth

function setOAuth()
{
    //  pecl_oauth
    $oauth = new OAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_FORM);
    $oauth->enableDebug();
    try {
        if (isset($_GET['oauth_token'], $_SESSION['oauth_token_secret'])) {
            $oauth->setToken($_GET['oauth_token'], $_SESSION['oauth_token_secret']);
            $accessToken = $oauth->getAccessToken(TWITTER_ACCESS_URL);
            $_SESSION['oauth_token'] = $accessToken['oauth_token'];
            $_SESSION['oauth_token_secret'] = $accessToken['oauth_token_secret'];
            $response = $oauth->getLastResponse();
            parse_str($response, $get);
            if (!isset($get['user_id'])) {
                throw new Exception('Authentication failed.');
            }
        } else {
            $requestToken = $oauth->getRequestToken(TWITTER_REQUEST_URL);
            $_SESSION['oauth_token_secret'] = $requestToken['oauth_token_secret'];
            header('Location: ' . TWITTER_AUTHORIZE_URL . '?oauth_token=' . $requestToken['oauth_token']);
            die;
        }
    } catch (Exception $e) {
        var_dump($oauth->debugInfo);
        die($e->getMessage());
    }
}
开发者ID:napthats,项目名称:rtter_js_php,代码行数:27,代码来源:connect.php

示例5: authorize

 function authorize()
 {
     $oauth = new OAuth(Config::get('TWITTER_CONSUMER_KEY'), Config::get('TWITTER_CONSUMER_SECRET'), OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     $oauth->enableDebug();
     try {
         $request_token = $oauth->getRequestToken($this->request_token_url);
     } catch (OAuthException $e) {
         debug($oauth->debugInfo);
     }
     $url = $this->authorize_url . '?' . http_build_query(array('oauth_token' => $request_token['oauth_token'], 'callback_url'));
     print 'Authorize: ' . $url . "\n";
     system(sprintf('open %s', escapeshellarg($url)));
     fwrite(STDOUT, "Enter the PIN: ");
     $verifier = trim(fgets(STDIN));
     //$oauth->setToken($token, $request_token['oauth_token_secret']);
     //$access_token = $oauth->getAccessToken($this->access_token_url);
     $oauth->setToken($request_token['oauth_token'], $request_token['oauth_token_secret']);
     try {
         $access_token = $oauth->getAccessToken($this->access_token_url, NULL, $verifier);
     } catch (OAuthException $e) {
         debug($oauth->debugInfo);
     }
     printf("'TWITTER_TOKEN' => '%s',\n'TWITTER_TOKEN_SECRET' => '%s',\n", $access_token['oauth_token'], $access_token['oauth_token_secret']);
     exit;
 }
开发者ID:hubgit,项目名称:libapi,代码行数:25,代码来源:Twitter.php

示例6: getAuthorizationUrl

 public function getAuthorizationUrl()
 {
     $requestToken = $this->oauth->getRequestToken(self::URL_REQUEST);
     Session::set('Twitter_TokenSecret', $requestToken['oauth_token_secret']);
     # Session::set('Twitter_State', self::STATE_AUTH);
     return self::URL_AUTHORIZE . '?oauth_token=' . $requestToken['oauth_token'];
 }
开发者ID:joksnet,项目名称:php-old,代码行数:7,代码来源:Twitter.php

示例7: actionLogin

 public function actionLogin($backUrl = '/komunita')
 {
     try {
         $this->getSession('oauth')->back_url = $backUrl;
         $this->getUserDetailsAndLoginUser();
         return;
     } catch (OAuthException $E) {
         // not authentized -> continue below in asking for new token
     }
     // request token
     $request_token_info = $this->oauth->getRequestToken(self::REQUEST_TOKEN_URL);
     //save secret
     $this->getSession('oauth')->login_secret = $request_token_info['oauth_token_secret'];
     //redirect
     $this->redirectUrl(self::AUTHORIZE_URL . "?oauth_token=" . $request_token_info['oauth_token']);
 }
开发者ID:osmcz,项目名称:website,代码行数:16,代码来源:OauthPresenter.php

示例8: getAuthURL

 public static function getAuthURL($consumer_key, $consumer_secret, $callback = null)
 {
     $oauth = new OAuth($consumer_key, $consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     $request_token_info = $oauth->getRequestToken(GOOGLE_OAUTH_REQUEST_TOKEN_API . "?scope=" . SCOPE, $callback);
     $request_token = $request_token_info["oauth_token"];
     $request_secret = $request_token_info["oauth_token_secret"];
     return array("url" => "Location: " . GOOGLE_OAUTH_AUTHORIZE_API . "?oauth_token=" . $request_token . "&scope=" . SCOPE . "&domain=" . $consumer_key, "request_token" => $request_token, "request_secret" => $request_secret);
 }
开发者ID:copyfun,项目名称:Fusion-Tables-to-HTML-Table,代码行数:8,代码来源:oauth_ext.php

示例9: ilost_get_fanauthorize

function ilost_get_fanauthorize()
{
    $o = new OAuth(fan_akey, fan_skey);
    $keys = $o->getRequestToken();
    $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, fan_callback);
    $_SESSION['temp'] = $keys;
    return $aurl;
}
开发者ID:xuui,项目名称:iLost,代码行数:8,代码来源:fanfou.php

示例10: oauth_login

function oauth_login()
{
    global $error;
    try {
        $oauth = new OAuth(CLIENT_ID, CLIENT_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
        $request_token_info = $oauth->getRequestToken(OSM_OAUTH_URL . 'request_token');
        $_SESSION['secret'] = $request_token_info['oauth_token_secret'];
        header('Location: ' . OSM_OAUTH_URL . "authorize?oauth_token=" . $request_token_info['oauth_token']);
        exit;
    } catch (OAuthException $E) {
        $error = 'OAuth error ' . $E->getCode() . ': ' . $E->getMessage();
    }
}
开发者ID:tyrasd,项目名称:Level0,代码行数:13,代码来源:osmapi.php

示例11: getTemporaryCredentials

 public static function getTemporaryCredentials()
 {
     try {
         $request_token_url = \Fuel\Core\Config::get('evernote.evernote_server') . '/oauth';
         $oauth = new \OAuth(\Fuel\Core\Config::get('evernote.consumer_key'), \Fuel\Core\Config::get('evernote.consumer_secret'));
         $request_token_info = $oauth->getRequestToken($request_token_url, getCallbackUrl());
         if ($request_token_info) {
             \Fuel\Core\Session::set('requestToken', $request_token_info['oauth_token']);
             \Fuel\Core\Session::set('requestTokenSecret', $request_token_info['oauth_token_secret']);
             return TRUE;
         }
     } catch (OAuthException $e) {
     }
     return false;
 }
开发者ID:rizumita,项目名称:fuel-evernote,代码行数:15,代码来源:evernote.php

示例12: authorize

 protected function authorize($sKey, $sSecret)
 {
     if ($this->isAuthorized()) {
         return true;
     }
     try {
         $oConsumer = new OAuth($sKey, $sSecret);
         $oConsumer->setAuthType(OAUTH_AUTH_TYPE_URI);
         $oConsumer->enableDebug();
         $bToken = bx_get('oauth_token') !== false;
         $mixedSecret = $this->oSession->getValue('sys_oauth_secret');
         if (!$bToken && $mixedSecret !== false) {
             $this->oSession->unsetValue('sys_oauth_secret');
             $mixedSecret = false;
         }
         //--- Get request token and redirect to authorize.
         if (!$bToken && $mixedSecret === false) {
             $aRequestToken = $oConsumer->getRequestToken(BX_DOL_OAUTH_URL_REQUEST_TOKEN);
             if (empty($aRequestToken)) {
                 return _t('_adm_err_oauth_cannot_get_token');
             }
             if ($this->isServerError($aRequestToken)) {
                 return $this->processServerError($aRequestToken);
             }
             $this->oSession->setValue('sys_oauth_secret', $aRequestToken['oauth_token_secret']);
             return _t('_adm_msg_oauth_need_authorize', bx_append_url_params(BX_DOL_OAUTH_URL_AUTHORIZE, array('oauth_token' => $aRequestToken['oauth_token'], 'sid' => bx_site_hash())));
         }
         //--- Get access token.
         if ($bToken && $mixedSecret !== false) {
             $oConsumer->setToken(bx_get('oauth_token'), $mixedSecret);
             $aAccessToken = $oConsumer->getAccessToken(bx_append_url_params(BX_DOL_OAUTH_URL_ACCESS_TOKEN, array('oauth_verifier' => bx_get('oauth_verifier'))));
             if (empty($aAccessToken)) {
                 return _t('_adm_err_oauth_cannot_get_token');
             }
             if ($this->isServerError($aAccessToken)) {
                 return $this->processServerError($aAccessToken);
             }
             $this->oSession->setValue('sys_oauth_token', $aAccessToken['oauth_token']);
             $this->oSession->setValue('sys_oauth_secret', $aAccessToken['oauth_token_secret']);
             $this->oSession->setValue('sys_oauth_authorized', 1);
             $this->oSession->setValue('sys_oauth_authorized_user', (int) bx_get('oauth_user'));
             return true;
         }
     } catch (OAuthException $e) {
         return _t('_adm_err_oauth_cannot_get_token');
     }
 }
开发者ID:blas-dmx,项目名称:trident,代码行数:47,代码来源:BxDolStudioOAuthLib.php

示例13: get_temporary_credentials

 public static function get_temporary_credentials()
 {
     $consumer_key = Config::get('evernote.oauth_consumer_key');
     $consumer_secret = Config::get('evernote.oauth_consumer_secret');
     $callback_url = Config::get('evernote.callback_url');
     $request_token_url = Config::get('evernote.evernote_server');
     $request_token_url .= Config::get('evernote.request_token_path');
     try {
         $oauth = new OAuth($consumer_key, $consumer_secret);
         $request_token_info = $oauth->getRequestToken($request_token_url, $callback_url);
         if ($request_token_info) {
             return array('oauth_token' => $request_token_info['oauth_token'], 'oauth_token_secret' => $request_token_info['oauth_token_secret']);
         }
     } catch (OAuthException $e) {
         Log::error('Error obtaining temporary credentials: ' . $e->getMessage());
     }
 }
开发者ID:SerdarSanri,项目名称:laravel-evernote,代码行数:17,代码来源:evernote.php

示例14: GetRequestToken

 /**
  * @see OAuthHanlder::GetRequestToken()
  */
 public function GetRequestToken($credentials, $scope, $server = NULL, $callbackUrl = NULL, $applicationName = NULL)
 {
     $oauth = new OAuth($credentials['oauth_consumer_key'], $credentials['oauth_consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     $oauth->setRequestEngine(OAUTH_REQENGINE_CURL);
     $oauth->setVersion('1.0a');
     $params = array('scope' => $scope);
     if (!isset($callbackUrl)) {
         $callbackUrl = parent::$DEFAULT_CALLBACK_URL;
     }
     if (isset($applicationName)) {
         $params['xoauth_displayname'] = $applicationName;
     }
     $endpoint = $this->GetRequestEndpoint($server, $params);
     $response = $oauth->getRequestToken($endpoint, $callbackUrl);
     $credentials['oauth_token'] = $response['oauth_token'];
     $credentials['oauth_token_secret'] = $response['oauth_token_secret'];
     return $credentials;
 }
开发者ID:trancerr,项目名称:apiadlib,代码行数:21,代码来源:PeclOAuthHandler.php

示例15: indexAction

 public function indexAction()
 {
     // $page = new Page('auth');
     // return new Response($page);
     try {
         $oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
         $requestTokenInfo = $oauth->getRequestToken(REQUEST_TOKEN_URL, $this->getCallbackUrl());
         if ($requestTokenInfo) {
             $_SESSION['requestToken'] = $requestTokenInfo['oauth_token'];
             $_SESSION['requestTokenSecret'] = $requestTokenInfo['oauth_token_secret'];
             return new RedirectResponse($this->getAuthorizationUrl($requestTokenInfo['oauth_token']));
         } else {
             return new FatalErrorResponse('Failed to obtain temporary credentials: ' . $oauth->getLastResponse());
         }
     } catch (OAuthException $e) {
         return new FatalErrorResponse('Error obtaining temporary credentials: ' . $e->getMessage());
     }
 }
开发者ID:ryunhe,项目名称:everidea,代码行数:18,代码来源:auth.php


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