I can't get post requests to the twitter api to work. Login & GET requests seem to work fine though. I always get this reponse:
401 Authorization Required response:
{"errors":[{"code":32,"message":"Could not authenticate you."}]}
I'm using Laravel 5.3, Guzzle 6.3 and Guzzle/oauth-subscriber 0.3. Here's my code:
$stack = HandlerStack::create();
$middleware = new Oauth1([
'consumer_key' => env('TWITTER_CLIENT_ID'),
'consumer_secret' => env('TWITTER_CLIENT_SECRET'),
'token' => env('TWITTER_TOKEN'),
'token_secret' => env('TWITTER_TOKEN_SECRET')
]);
$stack->push($middleware);
$client = new Client([
'base_uri' => 'https://api.twitter.com/1.1/',
'handler' => $stack
]);
$res = $client->post(
'account/update_profile_image.json?image=' . $avatar,
[
'auth' => 'oauth',
]
);
My app settings in Twitters' dev page is set to read & write, so that isn't the problem. Regenerated the keys once, no dice. What am I doing wrong here?