Fixes to parameter merge (actually merge parameters, duh)

This commit is contained in:
jr conlin
2009-02-17 10:51:07 -08:00
parent b1e271ab02
commit 00a96ef829
2 changed files with 17 additions and 7 deletions
+9 -3
View File
@@ -106,9 +106,13 @@ class OAuthSimple {
* @param {string,object} List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash)
*/
function setParameters ($parameters=Array()) {
if (is_string($parameters))
$parameters = $this->_parseParameterString($parameters);
$this->_parameters = $parameters;
if (empty($this->_parameters))
$this->_parameters = $parameters;
elseif (!empty($parameters))
$this->_parameters = array_merge($this->_parameters,$parameters);
if (empty($this->_parameters[oauth_nonce]))
$this->_getNonce();
if (empty($this->_parameters[oauth_timestamp]))
@@ -119,7 +123,7 @@ class OAuthSimple {
$this->_getAccessToken();
if (empty($this->_parameters[oauth_signature_method]))
$this->setSignatureMethod();
//error_log('parameters: '.print_r($this,1));
return $this;
}
@@ -290,6 +294,7 @@ class OAuthSimple {
else
$result[$key]=$token;
}
//error_log('Parse parameters : '.print_r($result,1));
return $result;
}
@@ -339,7 +344,7 @@ class OAuthSimple {
}
function _getTimeStamp() {
return $this->_parameters['oauth_timestamp'] = time();
return $this->_parameters['stamp'] = time();
}
function _normalizedParameters() {
@@ -371,6 +376,7 @@ class OAuthSimple {
case 'HMAC-SHA1':
$sigString = $this->_oauthEscape($this->_action).'&'.$this->_oauthEscape($this->_path).'&'.$this->_oauthEscape($this->_normalizedParameters());
error_log('SBS: '.$sigString);
return base64_encode(hash_hmac('sha1',$sigString,$secretKey,true));
default:
+8 -4
View File
@@ -13,10 +13,10 @@
// Some sample argument values
// You can pass in arguments either as a string of URL characters:
$argumentsAsString = "term=rat&expand=formats,synopsis&max_results=1&boo=foo&boo=fie";
$argumentsAsString = "term=mac%20and+me&expand=formats,synopsis&max_results=1";
// or a hash:
$argumentsAsObject = Array(
term=>'rat',
term=>'the prisoner',
expand=>'formats,synopsis',
max_results=> '1',
);
@@ -57,8 +57,12 @@
<h1>Test Document</h1>
<ol>
<li><a href="<?php print $sample1Results['signed_url'] ?>">First Link</a><br />
<?php print $sample1Results['signed_url'] ?></li>
<li><a href="<?php print $sample2Results['signed_url'] ?>">Second Link</a></li>
</li>
<li><a href="<?php print $sample2Results['signed_url'] ?>">Second Link</a>
<?php /*
<pre> <?php print_r($sample2Results); ?> </pre>
*/ ?>
</li>
<li><a href="<?php print $sample3Results['signed_url'] ?>">Third Link</a></li>
</ol>
<a href="index.phps">Source for index</a><br />