本文整理汇总了PHP中OAuthRequester::getParam方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuthRequester::getParam方法的具体用法?PHP OAuthRequester::getParam怎么用?PHP OAuthRequester::getParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuthRequester
的用法示例。
在下文中一共展示了OAuthRequester::getParam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setcookie
function request_and_verify_request_token()
{
// If there exists any active session, destroy it for simplicity's sake.
$this->log_out();
// create a temp user and make a cookie for his record
$this->user_id = create_temp_user();
setcookie(COOKIE_NAME, get_session_id_from_user_id($this->user_id));
// At this point, we shouldn't have anything in the DB with a record of this transaction.
// Set up the required parameters to recognize an OAuth provider -- known in this OAuthPHP lib as
// a record in the oauth_consumer_registry table.
$server = array('consumer_key' => CONSUMER_KEY, 'consumer_secret' => CONSUMER_SECRET, 'server_uri' => ROOT_TYPEPAD_API_URL, 'signature_methods' => array('PLAINTEXT'), 'request_token_uri' => $this->get_api_endpoint(TP_OAUTH_REQUEST_TOKEN_URL), 'authorize_uri' => $this->get_api_endpoint(TP_OAUTH_AUTH_URL), 'access_token_uri' => $this->get_api_endpoint(TP_OAUTH_ACCESS_TOKEN_URL));
// See which known services exist for this user
$servers = $this->store->listServers('', $this->user_id);
// Refresh the known OAuth providers for this user by deleting them if they already exist...
foreach ($servers as $server_item) {
if ($server_item['consumer_key'] == CONSUMER_KEY && $server_item['user_id'] == $this->user_id) {
// debug ("User_id = " . $this->user_id);
$this->store->deleteServer(CONSUMER_KEY, $this->user_id);
}
}
// otherwise, create a new record of this OAuth provider.
$consumer_key = $this->store->updateServer($server, $this->user_id);
/*
* These methods from this OAuth PHP lib don't create the right type of GET request...
$options = array();
$options[CURLOPT_HTTPHEADER] = $server;
$token = OAuthRequester::requestRequestToken(CONSUMER_KEY, $user_id); //, '', 'GET', $options);
$token = OAuthRequester::requestRequestToken(CONSUMER_KEY, $user_id, '', 'GET');
*/
$r = $this->store->getServer(CONSUMER_KEY, $this->user_id);
// This creates a generic Request object, so we'll have to fill in the rest...
$oauth = new OAuthRequester($this->get_api_endpoint(TP_OAUTH_REQUEST_TOKEN_URL), '', '');
$oauth->setParam('oauth_callback', CALLBACK_URL);
// ..and this adds more parameters, like the timestamp, nonce, version, signature method, etc
$oauth->sign($this->user_id, $r);
// Begin to build the URL string with the request token endpoint
$final_url = $this->get_api_endpoint(TP_OAUTH_REQUEST_TOKEN_URL) . "?";
$parameters = array('timestamp', 'callback', 'nonce', 'consumer_key', 'version', 'signature_method', 'signature');
foreach ($parameters as $parm) {
$final_url .= 'oauth_' . $parm . '=' . $oauth->getParam('oauth_' . $parm) . '&';
}
/* Now execute the long query that may look something like this:
https://www.typepad.com/secure/services/oauth/request_token ?
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
*/
// debug ("Final Url = $final_url");
// and go ahead and execute the request.
$handle = fopen($final_url, "rb");
$doc = stream_get_contents($handle);
$response_array = explode("&", $doc);
// debug ("Response from request = ^" . var_dump($response_array));
// TODO: Verbose error handling
// Store the results!
$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.
$this->store->addServerToken(CONSUMER_KEY, 'request', $response['oauth_token'], $response['oauth_token_secret'], $this->user_id, '');
// var_dump($oauth);
// debug ("After creating a simple request token, store obj = ^ ");
$this->oauth_token = $response['oauth_token'];
}
示例2: OAuthRequester
$options[CURLOPT_HTTPHEADER] = $server;
$token = OAuthRequester::requestRequestToken(CONSUMER_KEY, $user_id); //, '', 'GET', $options);
$token = OAuthRequester::requestRequestToken(CONSUMER_KEY, $user_id, '', 'GET');
*/
$r = $store->getServer(CONSUMER_KEY, $user_id);
// This creates a generic Request object.
$oauth = new OAuthRequester($endpoint_strs['oauth-request-token-endpoint'], '', '');
// $oauth->setParam('oauth_callback', 'http://127.0.0.1/claire/oauth/beta.php');
$oauth->setParam('oauth_callback', CALLBACK_URL);
// ..and this adds more parameters, like the timestamp, nonce, version, signature method, etc
$oauth->sign($user_id, $r);
// $final_url = "https://www.typepad.com/secure/services/oauth/request_token?";
$final_url = $endpoint_strs['oauth-request-token-endpoint'] . "?";
$parameters = array('timestamp', 'callback', 'nonce', 'consumer_key', 'version', 'signature_method', 'signature');
foreach ($parameters as $parm) {
$final_url .= 'oauth_' . $parm . '=' . $oauth->getParam('oauth_' . $parm) . '&';
}
/* Now execute the long query that may look something like this:
https://www.typepad.com/secure/services/oauth/request_token ?
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);