本文整理汇总了PHP中OAuthRequest::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuthRequest::redirect方法的具体用法?PHP OAuthRequest::redirect怎么用?PHP OAuthRequest::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuthRequest
的用法示例。
在下文中一共展示了OAuthRequest::redirect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TPSession
<?php
include_once "oauth-php-98/library/OAuthStore.php";
include_once "oauth-php-98/library/OAuthRequester.php";
include_once 'config.php';
// Create a new session object. It will flush any local cookies that you have in case
// you hit this page in error, since this should be the "Login" page.
$user_session = new TPSession();
// Obtain a Request token from TypePad.
$user_session->request_and_verify_request_token();
// Next step in the OAuth Dance: Redirect your user to the Provider.
// this redirect() method is courtesy of our OAuthPHP lib. Parameters:
// 1 = the URL to redirect to
// 2 = a list of parameters. In our case, it's the Request token.
/*
* 'oauth-authorization-page' is deprecated in favor of 'oauthAuthorizationUrl'.
OAuthRequest::redirect($user_session->get_api_endpoint('oauth-authorization-page'),
array('oauth_token' => $user_session->oauth_token));
*/
OAuthRequest::redirect($user_session->get_api_endpoint(TP_OAUTH_AUTH_URL), array('oauth_token' => $user_session->oauth_token));
// FYI: HTML is forbidden in this file, since the redirect's headers cannot be written!!
?>
示例2: fopen
oauth_signature=n3lQROBcPnBZvEgplUzHcgkUCrA%3D &
oauth_timestamp=1269811986 &
oauth_callback=http%3A%2F%2F127.0.0.1%3A5000%2Flogin-callback &
oauth_nonce=853433351 &
oauth_consumer_key=c5139cef2985b86d &
oauth_version=1.0 &
oauth_signature_method=HMAC-SHA1
*/
$handle = fopen($final_url, "rb");
$doc = stream_get_contents($handle);
$response_array = explode("&", $doc);
// Store the results! Anything but 200 will croak to the browser for now.
$response = array();
foreach ($response_array as $response_str) {
$pair = explode("=", $response_str);
$response[$pair[0]] = $pair[1];
}
// Instead of storing the Request token as a cookie, write it to the db.
$store->addServerToken(CONSUMER_KEY, 'request', $response['oauth_token'], $response['oauth_token_secret'], $user_id, '');
var_dump($oauth);
debug("After creating a simple request token, store obj = ^ ");
/*
Next step in the OAuth Dance: Redirect your user to the Provider.
*/
$query_params = array();
$query_params['oauth_token'] = $response['oauth_token'];
// the redirect() method is from the OAuth library
OAuthRequest::redirect($endpoint_strs['oauth-authorization-page'], $query_params);
// HTML is forbidden in this file, since the redirect's headers cannot be written!!
?>