twitteroauth
twitteroauth copied to clipboard
account/verify_credentials returns NULL
I'm trying to get the user information when the user is redirected to the callback url but it returns NULL.
I also tried to change the API version but the result is the same.
$oauth_verifier = $_GET['oauth_verifier'];
$oauth_token = $_GET['oauth_token'];
$twitteroauth = new TwitterOAuth($consumerKey, $consumerSecret, $oauth_token, $_SESSION['oauth_token_secret']);
$twitteroauth->setApiVersion('1.1'); // Specify the version you want to use
$access_token = $twitteroauth->oauth("oauth/access_token", ["oauth_verifier" => $oauth_verifier]);
$twitteroauth = new TwitterOAuth($consumerKey, $consumerSecret, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$user = $twitteroauth->get("account/verify_credentials");
print_r($user);
Done.
` $twitterOAuth = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
$twitterOAuth->setApiVersion('1.1');
$userInfo = $twitterOAuth->get("account/verify_credentials");
if ($twitterOAuth->getLastHttpCode() == 200) {
print_r($userInfo);
} else {
echo "Error: Unable to retrieve user information";
}`
You got it working?
@abraham @levanigongadze had the same issue and what he commented last, worked for me.
It's important to specify the setApiVersion. :)
Just leaving this comment in case someone goes through this.