|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-11-21 10:42 UTC] hans at shapeways dot com
Description:
------------
The example code
return "authentification_url=".$this->authentification_url."&oauth_token=".$token."&oauth_token_secret=".$token_secret."&oauth_callback_confirmed=true";
is interpreted fine by getRequestToken, but when you fix the URL by replacing the first & with a ? then getRequestToken misses the first query item. The resulting array then looks like :
array(3) {
["authentication_url"]=>
string(95) "http://testhost/login?oauth_token=3f47ff5646916c1ba1365896ac30ed171d86a803"
["oauth_token_secret"]=>
string(40) "cf5213dd32b9b8150bbc3e48c993c569c3e47baa"
["oauth_callback_confirmed"]=>
string(4) "true"
}
The oauth_token is still glued to the authentication_url.
Test script:
---------------
Feed this to getRequestToken :
return "authentification_url=".$this->authentification_url."?oauth_token=".$token."&oauth_token_secret=".$token_secret."&oauth_callback_confirmed=true";
( ps. here's a client-side workaround to fix the $info result array :
if ( array_key_exists('oauth_token_secret', $info) &&
array_key_exists('authentication_url', $info) &&
! array_key_exists('oauth_token', $info)) {
$urlArray = parse_url($info['authentication_url']);
$info['authentication_url'] = $urlArray['scheme'] .'://'. $urlArray['host'] . $urlArray['path'];
parse_str($urlArray['query']);
$info['oauth_token'] = $oauth_token;
}
)
Expected result:
----------------
array(3) {
["authentication_url"]=>
string(21) "http://testhost/login"
["oauth_token"]=>
string(40) "3f47ff5646916c1ba1365896ac30ed171d86a803"
["oauth_token_secret"]=>
string(40) "cf5213dd32b9b8150bbc3e48c993c569c3e47baa"
["oauth_callback_confirmed"]=>
string(4) "true"
}
Actual result:
--------------
array(3) {
["authentication_url"]=>
string(95) "http://testhost/login?oauth_token=3f47ff5646916c1ba1365896ac30ed171d86a803"
["oauth_token_secret"]=>
string(40) "cf5213dd32b9b8150bbc3e48c993c569c3e47baa"
["oauth_callback_confirmed"]=>
string(4) "true"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Using x-www-form-urlencoding in the provider like this : header('Content-type: application/x-www-form-urlencoded'); echo "authentication_url=". urlencode("http://". $_SERVER['SERVER_NAME'] . "/login?"). "oauth_token=" .$requestToken->getToken() ."&oauth_token_secret=".$requestToken->getTokenSecret() ."&oauth_callback_confirmed=true"; does not help. (But is indeed closer to the RFC, thanks for the hint !). A var_dump of the array that getRequestToken returns still shows the oauth_token glued to the authentication_url part. So I think the bug remains.I think you may have misread the specs. getRequestToken() expects a string that conforms to application/x-www-form-urlencoded. You can generate this by simply using http_build_query(): return http_build_query(array( 'authentification_url' => 'http://localhost/script?', 'oauth_token' => 'doremi', 'oauth_token_secret' => 'fasola', 'oauth_callback_confirmed' => 'true' )); Closing this bug.