本文整理汇总了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');
}
}
示例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());
}
}
示例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";
}
}
示例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();
}
示例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;
}