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


PHP OAuthServer::fetch_request_token方法代码示例

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


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

示例1: handle

 /**
  * Handle a request for temporary OAuth credentials
  *
  * Make sure the request is kosher, then emit a set of temporary
  * credentials -- AKA an unauthorized request token.
  *
  * @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);
     try {
         $req = OAuthRequest::from_request();
         // verify callback
         if (!$this->verifyCallback($req->get_parameter('oauth_callback'))) {
             throw new OAuthException("You must provide a valid URL or 'oob' in oauth_callback.", 400);
         }
         // check signature and issue a new request token
         $token = $server->fetch_request_token($req);
         common_log(LOG_INFO, sprintf("API OAuth - Issued request token %s for consumer %s with oauth_callback %s", $token->key, $req->get_parameter('oauth_consumer_key'), "'" . $req->get_parameter('oauth_callback') . "'"));
         // return token to the client
         $this->showRequestToken($token);
     } catch (OAuthException $e) {
         common_log(LOG_WARNING, 'API OAuthException - ' . $e->getMessage());
         // Return 401 for for bad credentials or signature problems,
         // and 400 for missing or unsupported parameters
         $code = $e->getCode();
         $this->clientError($e->getMessage(), empty($code) ? 401 : $code, 'text');
     }
 }
开发者ID:ronhuang,项目名称:statusnet,代码行数:36,代码来源:apioauthrequesttoken.php

示例2: request_token

 public function request_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_request_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:unpush,项目名称:partuza,代码行数: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);
     try {
         $req = OAuthRequest::from_request();
         $token = $server->fetch_request_token($req);
         print $token;
     } catch (OAuthException $e) {
         common_log(LOG_WARNING, 'API OAuthException - ' . $e->getMessage());
         header('HTTP/1.1 401 Unauthorized');
         header('Content-Type: text/html; charset=utf-8');
         print $e->getMessage() . "\n";
     }
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:25,代码来源:apioauthrequesttoken.php

示例4: ATutorOAuthDataStore

<?php

/***********************************************************************/
/* 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';
$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_request_token($request);
    if ($token) {
        echo $token->to_string();
    }
} catch (OAuthException $e) {
    echo $e->getMessage();
} catch (Exception $e) {
    echo $e->getMessage();
}
开发者ID:genaromendezl,项目名称:ATutor,代码行数:31,代码来源:common.inc.php

示例5: request_token

function request_token(&$vars)
{
    extract($vars);
    if (!(environment('openid_version') > 1) || (!$db->has_table('oauth_consumers') || !$db->has_table('oauth_tokens'))) {
        $db->create_openid_tables();
    }
    wp_plugin_include(array('wp-oauth'));
    $consumerkey = $db->escape_string(urldecode($_POST['oauth_consumer_key']));
    $consumer_result = $db->get_result("SELECT consumer_key FROM oauth_consumers WHERE consumer_key = '{$consumerkey}'");
    if (!$db->num_rows($consumer_result) > 0) {
        $result = $db->get_result("INSERT INTO oauth_consumers (consumer_key, secret, description) VALUES ('{$consumerkey}', '', 'Unidentified Consumer')");
    }
    $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);
    $params = array();
    foreach ($_POST as $key => $val) {
        if (!($key == 'request_token')) {
            $params[$key] = $val;
        }
    }
    $req = OAuthRequest::from_request();
    $token = $server->fetch_request_token($req);
    header('Status: 200 OK');
    print $token->to_string() . '&xoauth_token_expires=' . urlencode($store->token_expires($token));
    exit;
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:30,代码来源:omb.php


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