twitteroauth icon indicating copy to clipboard operation
twitteroauth copied to clipboard

account/verify_credentials returns NULL

Open levanigongadze opened this issue 2 years ago • 3 comments

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);

levanigongadze avatar Feb 21 '24 15:02 levanigongadze

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";
    }`

levanigongadze avatar Feb 21 '24 15:02 levanigongadze

You got it working?

abraham avatar Mar 03 '24 15:03 abraham

@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.

maaprofit avatar Jun 26 '24 15:06 maaprofit