當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OAuthServer::fetch_access_token方法代碼示例

本文整理匯總了PHP中OAuthServer::fetch_access_token方法的典型用法代碼示例。如果您正苦於以下問題:PHP OAuthServer::fetch_access_token方法的具體用法?PHP OAuthServer::fetch_access_token怎麽用?PHP OAuthServer::fetch_access_token使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OAuthServer的用法示例。


在下文中一共展示了OAuthServer::fetch_access_token方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * Class handler.
  *
  * @param array $args array of arguments
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $datastore = new ApiStatusNetOAuthDataStore();
     $server = new OAuthServer($datastore);
     $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
     $server->add_signature_method($hmac_method);
     $atok = $app = null;
     // XXX: Insist that oauth_token and oauth_verifier be populated?
     // Spec doesn't say they MUST be.
     try {
         $req = OAuthRequest::from_request();
         $this->reqToken = $req->get_parameter('oauth_token');
         $this->verifier = $req->get_parameter('oauth_verifier');
         $app = $datastore->getAppByRequestToken($this->reqToken);
         $atok = $server->fetch_access_token($req);
     } catch (Exception $e) {
         common_log(LOG_WARNING, 'API OAuthException - ' . $e->getMessage());
         common_debug(var_export($req, true));
         $code = $e->getCode();
         $this->clientError($e->getMessage(), empty($code) ? 401 : $code, 'text');
         return;
     }
     if (empty($atok)) {
         // Token exchange failed -- log it
         $msg = sprintf('API OAuth - Failure exchanging OAuth request token for access token, ' . 'request token = %s, verifier = %s', $this->reqToken, $this->verifier);
         common_log(LOG_WARNING, $msg);
         // TRANS: Client error given from the OAuth API when the request token or verifier is invalid.
         $this->clientError(_('Invalid request token or verifier.'), 400, 'text');
     } else {
         common_log(LOG_INFO, sprintf("Issued access token '%s' for application %d (%s).", $atok->key, $app->id, $app->name));
         $this->showAccessToken($atok);
     }
 }
開發者ID:microcosmx,項目名稱:experiments,代碼行數:41,代碼來源:apioauthaccesstoken.php

示例2: access_token

 public function access_token($params)
 {
     try {
         $server = new OAuthServer($this->oauthDataStore);
         $server->add_signature_method(new OAuthSignatureMethod_HMAC_SHA1());
         $server->add_signature_method(new OAuthSignatureMethod_PLAINTEXT());
         $request = OAuthRequest::from_request();
         $token = $server->fetch_access_token($request);
         if ($token) {
             echo $token->to_string();
         }
     } catch (OAuthException $e) {
         $this->sendServerError(401, $e->getMessage());
     } catch (Exception $e) {
         $this->sendServerError(400, $e->getMessage());
     }
 }
開發者ID:vuxuandung,項目名稱:Partuza-bundle,代碼行數:17,代碼來源:oauth.php

示例3: handle

 /**
  * Class handler.
  *
  * @param array $args array of arguments
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $datastore = new ApiStatusNetOAuthDataStore();
     $server = new OAuthServer($datastore);
     $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
     $server->add_signature_method($hmac_method);
     $atok = null;
     try {
         $req = OAuthRequest::from_request();
         $atok = $server->fetch_access_token($req);
     } catch (OAuthException $e) {
         common_log(LOG_WARNING, 'API OAuthException - ' . $e->getMessage());
         common_debug(var_export($req, true));
         $this->outputError($e->getMessage());
         return;
     }
     if (empty($atok)) {
         common_debug('couldn\'t get access token.');
         print "Token exchange failed. Has the request token been authorized?\n";
     } else {
         print $atok;
     }
 }
開發者ID:sukhjindersingh,項目名稱:PHInest-Solutions,代碼行數:31,代碼來源:apioauthaccesstoken.php

示例4: ATutorOAuthDataStore

/***********************************************************************/
/* ATutor															   */
/***********************************************************************/
/* Copyright (c) 2002-2010                                             */
/* Inclusive Design Institute	                                       */
/* http://atutor.ca													   */
/*																	   */
/* This program is free software. You can redistribute it and/or	   */
/* modify it under the terms of the GNU General Public License		   */
/* as published by the Free Software Foundation.					   */
/***********************************************************************/
// $Id$
require_once 'OAuth.php';
require_once '../Shindig/ATutorOAuthDataStore.php';
$oauthDataStore = new ATutorOAuthDataStore();
try {
    $server = new OAuthServer($oauthDataStore);
    $server->add_signature_method(new OAuthSignatureMethod_HMAC_SHA1());
    $server->add_signature_method(new OAuthSignatureMethod_PLAINTEXT());
    $request = OAuthRequest::from_request();
    $token = $server->fetch_access_token($request);
    if ($token) {
        echo $token->to_string();
    }
    echo $token;
} catch (OAuthException $e) {
    echo $e->getMessage();
} catch (Exception $e) {
    echo $e->getMessage();
}
開發者ID:genaromendezl,項目名稱:ATutor,代碼行數:30,代碼來源:access_token.php

示例5: access_token

function access_token(&$vars)
{
    extract($vars);
    wp_plugin_include(array('wp-oauth'));
    $store = new OAuthWordpressStore();
    $server = new OAuthServer($store);
    $sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
    $plaintext_method = new OAuthSignatureMethod_PLAINTEXT();
    $server->add_signature_method($sha1_method);
    $server->add_signature_method($plaintext_method);
    $req = OAuthRequest::from_request();
    $token = $server->fetch_access_token($req);
    header('Status: 200 OK');
    print $token->to_string() . '&xoauth_token_expires=' . urlencode($store->token_expires($token));
    exit;
}
開發者ID:Br3nda,項目名稱:openmicroblogger,代碼行數:16,代碼來源:omb.php


注:本文中的OAuthServer::fetch_access_token方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。