PLhery / node-twitter-api-v2

Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
https://www.npmjs.com/package/twitter-api-v2
Apache License 2.0
1.24k stars 174 forks source link

[documentation] Rewrite the sample code using v2.tweet() instead of v1.tweet() because we unable to use v1.tweet() with free plan #486

Closed ry0y4n closed 11 months ago

ry0y4n commented 1 year ago

Thanks for the useful repository!!!

I think many users, including myself, would be on the free plan. Currently, users on the free plan do not have access to the v1 API endpoint. Therefore, in order to encourage more users to take advantage of this repository, I have rewritten the samples using v2.

In particular, the modification of doc/examples.md is important; simply rewriting v1 to v2 will not work. examples of working code is presented below (the former is used in this PR, but please let me know if you prefer the latter)

await client.v2.tweet({
  text: 'My tweet text with two images!',
  media: { media_ids: mediaIds }
});
await client.v2.tweet('My tweet text with two images!', 
{
  media: { media_ids: mediaIds }
});

Note: Similar updates may be needed for functions other than tweet(), but this PR focuses on the tweet() function only.

PLhery commented 11 months ago

Good point, thank you for your contribution!