J7mbo / twitter-api-php

The simplest PHP Wrapper for Twitter API v1.1 calls
MIT License
1.82k stars 802 forks source link

Error: Could not authenticate you when using retweet. #221

Closed amorino closed 6 years ago

amorino commented 7 years ago

I don't know what I'm missing, when I use the endpoint 'https://api.twitter.com/1.1/statuses/retweet/:id.json' with POST I get the error. When I use other POST method, the API return the correct result. I also checked the verify_credentials service, all good.

It's just that endpoint. The result:

{ "errors": [ { "code": 32, "message": "Could not authenticate you." } ] }

Vinlock commented 7 years ago

I'm getting this same error when using https://api.twitter.com/1.1/favorites/list.json 😢 help!

pda87 commented 7 years ago

I just encountered this same problem when trying to Retweet. I noticed that when Tweeting normally (/statuses/update.json), this works fine. update.json is also a POST request. When I was posting a status update, I used this code:

$url = 'https://api.twitter.com/1.1/statuses/update.json';
$requestMethod = 'POST';

$postfields = array(
    'status' => "$statusToPost"
);

$twitter = new TwitterAPIExchange($settings);
echo $twitter->buildOauth($url, $requestMethod)
->setPostfields($postfields)
->performRequest();

But, there are no $postfields to set when sending a Retweet request. There is one option that can be set: trim_user.

I've just tried this, using very similar code to the Update Status snippet above, but setting the $postfields array to this instead:

$postfields = array( 'trim_user' => "1" );

And the Retweet worked fine! Possibly a workaround?

J7mbo commented 7 years ago

Hey guys, I'm struggling to understand exactly what the issue is here? Retweets works, we have a test in tests/ that retweets successfully? Maybe take a look at that for a tweet example?

Not sure about the latest message here as well. If you guys still need help please comment and someone will try and help out, but I'm not seeing what the problem is. Are you forced to send $postfields or something?

Thunder33345 commented 7 years ago

also another issue that may be related,

first call account/verify_credentials which returns success second call to statuses/update which returns code 32 subsequent calls account/verify_credentials seems to fail

somehow if i recreate a new instance for each calls only call to statuses/update fails see here for code and log https://gist.github.com/Thunder33345/5d98bc99f3d9a5a87151f4631116f4e5 using latest on master branch

JulianBerger commented 6 years ago

It works fine when I send postfields.

J7mbo commented 6 years ago

Closing this as no response. If this is not the case, please feel free to re-open / create a new issue. Having to create a new object each time is one problem that will be rectified soon (#213).