Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return NULL #1212

Closed
amerhamdan3 opened this issue Nov 24, 2023 · 6 comments
Closed

return NULL #1212

amerhamdan3 opened this issue Nov 24, 2023 · 6 comments

Comments

@amerhamdan3
Copy link

What are you attempting to do
i am trying to do simple api request to twitter

Expected behavior
to return any thing than null

Actual behavior
NULL

Code example

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$content = $connection->get("account/verify_credentials");
var_dump($content);

i was trying to do more complex api but i was troubleshooting and returning to basics

Versions:

"abraham/twitteroauth": "^6.2",
"guzzlehttp/guzzle": "^7.8"

  • PHP: v 8.2.12
@abraham
Copy link
Owner

abraham commented Nov 25, 2023

It's probably an issue with the credentials. Though I would expect the response to be an error message.

@amerhamdan3
Copy link
Author

amerhamdan3 commented Nov 25, 2023 via email

@hizmarck
Copy link

@amerhamdan3 for me worked as you expected.
image

but I'm using version 5 of the library. 🤔

@hizmarck
Copy link

@amerhamdan3 The problem is that for version 6.x the default version configured is 2, and the endpoint that you are trying to get comes from the 1.1 , so, I tested and this worked:

 $connection = new TwitterOAuth($key, $secret);
 $connection->setApiVersion("1.1");
 $content = $connection->get("account/verify_credentials");

Regards

@amerhamdan3
Copy link
Author

@hizmarck Thank you now i am getting the error message ,, you are a saver

@KarlosFodaoBr
Copy link

@amerhamdan3 The problem is that for version 6.x the default version configured is 2, and the endpoint that you are trying to get comes from the 1.1 , so, I tested and this worked:

 $connection = new TwitterOAuth($key, $secret);
 $connection->setApiVersion("1.1");
 $content = $connection->get("account/verify_credentials");

Regards

ILOVEYOU

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants