themattharris / tmhOAuth

An OAuth 1.0A library written in PHP
Apache License 2.0
855 stars 335 forks source link

DELETE requests return HTTP 401: 32 - "Could not authenticate you" #203

Open sykezz opened 4 years ago

sykezz commented 4 years ago

DELETE requests on the new Direct Message endpoints doesn't seem to work, as they are returning HTTP/1.1 401 Authorization Required with response {"errors":[{"code":32,"message":"Could not authenticate you."}]}.

I don't have any issues with DELETE account_activity/all/:env_name/webhooks/:webhook_id or other endpoints (including POST direct_messages/events/new with PR #202) .

I've tried passing the id into parameters, but it returns HTTP 401:

$tmhOAuth->user_request([
  "method" => "DELETE"
  "host" => "direct_messages/events/destroy"
  "url" => "https://api.twitter.com/1.1/direct_messages/events/destroy.json"
  "params" => [
    "id" => "0000000"
  ]
  "multipart" => false
 ]);

I've also tried adding the id into the url as query parameters, but then it returns me HTTP/1.1 400 Bad Request with response {"errors":[{"code":38,"message":"id parameter is missing."}]}. Apparently, the query parameters weren't passed at all since it was filtered out in prepare_url() method, so I made some adjustments to work around it, and it lead me back to HTTP 401 again :/

$tmhOAuth->user_request([
  "method" => "DELETE"
  "host" => "direct_messages/events/destroy"
  "url" => "https://api.twitter.com/1.1/direct_messages/events/destroy.json?id=0000000"
  "params" => []
  "multipart" => false
 ]);

Furthermore, the follow PUT request has the same issue as well (requires PR #202 and c9f0f477).

$tmhOAuth->user_request([
  "method" => "PUT"
  "host" => "direct_messages/welcome_messages/update"
  "url" => "https://api.twitter.com/1.1/direct_messages/welcome_messages/update.json?id=1111"
  "params" => "{"message_data":{"text":"Updated welcome message"}}"
  "multipart" => false
 ]);

Any help would be great.