abraham / twitteroauth

The most popular PHP library for use with the Twitter OAuth REST API.
https://twitteroauth.com
MIT License
4.3k stars 1.71k forks source link

Getting null on account/verify_credentials #1197

Closed Sourovahmad closed 1 year ago

Sourovahmad commented 1 year ago

i have a free account on twitter developer. on the developer portal i got the consumer key and secret. as well as the access token and secret. but when i call

$connection = new TwitterOAuth($consumerKey,$consumerSecret,$access_token,$access_token_secret);
$content = $connection->get("account/verify_credentials");
dd($content);

i got null. could anyone please explain me why is that ?

Vipin-SBM commented 1 year ago

i have faced same issue too. is there any fix?

abraham commented 1 year ago

What do you get from these after you make the request?

$connection->getLastHttpCode();
$connection->getLastBody();
Vipin-SBM commented 1 year ago

i think we cannot use if we have free version. s, this is not considered as bug as i manage to post a tweet using post. Official websites of twitter says "write-only use cases and testing the Twitter API for v2".

Vipin-SBM commented 1 year ago

if ($connection->getLastHttpCode() == 201) { echo "API request successful! HTTP response code: " . $connection->getLastHttpCode() . "\n"; echo "API response:\n"; print_r($response); } else { echo "API request failed! HTTP response code: " . $connection->getLastHttpCode(); }

Vipin-SBM commented 1 year ago

i am getting 403 error code (referes to forbidden in official site) for get method and success for post method and i have free version of twitter. Do want me to test anything if i have 403 code. i assume it's because of free version.

abraham commented 1 year ago

Yep. That looks like the reason.

Sourovahmad commented 1 year ago

What do you get from these after you make the request?

$connection->getLastHttpCode();
$connection->getLastBody();

sorry for late reply.

i got 404 on $connection->getLastHttpCode(); and null on $connection->getLastBody()

my codes are simple using laravel version 8.0 and using "abraham/twitteroauth": "^6.1",

Vipin-SBM commented 1 year ago

hi there, https://developer.twitter.com/en/support/twitter-api/error-troubleshooting please refer to this. i think you check that you are using valid parameters and the correct URI for the endpoint you’re using.

Thank you !