stefanuros / deno_twitter_api

A Deno Module to make accessing the Twitter API from Deno a bit easier.
MIT License
12 stars 4 forks source link

Streamlined some code + added support for media uploads #10

Closed bram-dingelstad closed 9 months ago

bram-dingelstad commented 2 years ago

Hey there @stefanuros! Thank you so much for this module.

I've been using it to send simple tweets for a Notion integration I'm making. However, when writing support for media uploads it seemed a little bit lacking in certain places. I've updated the code to work for media uploads while also streamlining some other stuff that I ran into.

I'll clarify all of this in separate comments on the code. Let me know if you disagree, want changes or otherwise have comments!

Thanks 🙏🏻

bram-dingelstad commented 2 years ago

Other way around! (atleast in my case) There’s plenty of cases where the docs say otherwise and it should only accept multipart/form-data, but trying to make it work to the spec of the docs didn’t work for me. When reverse engineering a Node.js library I just found out that people just force the application/x-www-form-urlencoded body when it should be multipart/form-data. And it worked! I guess v1.1 is just that archaic?

On 7 Nov 2021, at 11:36 PM, Stefan Urosevic @.***> wrote:

@stefanuros commented on this pull request.


In twitterApi.ts:

-

  • // console.log(request);
  • // console.log(headers)
  • let headers = new Headers(
  • {
  • 'Authorization': this.createAuthHeader(oauth_nonce, oauth_timestamp, oauth_signature),
  • 'Content-Type': 'application/x-www-form-urlencoded'
  • }
  • );
  • let request = new Request(
  • this.baseUrl + path,
  • {
  • method,
  • headers,
  • body: new URLSearchParams(options)

Oh is that where the difference comes in? v2 uses everything in body instead of query params?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.