Closed dimisus closed 9 years ago
I didn't understand you code. Try to refactor your code following this doc. https://github.com/matheusmariano/tumblr.php/blob/improving-docs/README.md
@dimisus I believe you're just missing a trim()
on your oauth_verifier
. I constructed a more minimal version of your code and can successfully complete the OAuth flow:
// Setup
$client = new Tumblr\API\Client('...','...');
$requestHandler = $client->getRequestHandler();
$requestHandler->setBaseUrl('https://www.tumblr.com/');
// Request Token
$resp = $requestHandler->request('POST', 'oauth/request_token', array());
$request_tokens = array();
parse_str($resp->body, $request_tokens);
$client->setToken($request_tokens['oauth_token'], $request_tokens['oauth_token_secret']);
// Authorization
echo 'https://www.tumblr.com/oauth/authorize?oauth_token=' . $request_tokens['oauth_token'] . "\n> ";
$stdin_handle = fopen('php://stdin', 'r');
$oauth_verifier = trim(fgets($stdin_handle));
// Access token
$resp = $requestHandler->request('POST', 'oauth/access_token', array('oauth_verifier' => $oauth_verifier));
$access_tokens = array();
parse_str($resp->body, $access_tokens);
$client->setToken($access_tokens['oauth_token'], $access_tokens['oauth_token_secret']);
// Validate
$requestHandler->setBaseUrl('https://api.tumblr.com/');
echo $client->getUserInfo()->user->name . "\n";
I am trying since hours, I don't get it why the verifier does not work.
Appreciate any help.