Skip to content

Commit f46f5ab

Browse files
authored
update: In the documentation, rewrite the sample code using v2.tweet() instead of v1.tweet() because we unable to use v1.tweet() with free plan (#486)
1 parent e396cf7 commit f46f5ab

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const readOnlyClient = twitterClient.readOnly;
5858

5959
// Play with the built in methods
6060
const user = await readOnlyClient.v2.userByUsername('plhery');
61-
await twitterClient.v1.tweet('Hello, this is a test.');
61+
await twitterClient.v2.tweet('Hello, this is a test.');
6262
// You can upload media easily!
6363
await twitterClient.v1.uploadMedia('./big-buck-bunny.mp4');
6464
```

doc/examples.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ const mediaIds = await Promise.all([
160160
]);
161161

162162
// mediaIds is a string[], can be given to .tweet
163-
await client.v1.tweet('My tweet text with two images!', { media_ids: mediaIds });
163+
await client.v2.tweet({
164+
text: 'My tweet text with two images!',
165+
media: { media_ids: mediaIds }
166+
});
164167
```
165168

166169
### Reply to a tweet with a video that have subtitles

doc/rate-limiting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { ApiResponseError } from 'twitter-api-v2';
4747

4848
try {
4949
// Get a single tweet
50-
await client.v1.tweet('20');
50+
await client.v2.tweet('20');
5151
} catch (error) {
5252
if (error instanceof ApiResponseError && error.rateLimitError && error.rateLimit) {
5353
console.log(`You just hit the rate limit! Limit for this endpoint is ${error.rateLimit.limit} requests!`);
@@ -85,7 +85,7 @@ async function autoRetryOnRateLimitError<T>(callback: () => T | Promise<T>) {
8585
}
8686

8787
// Then use it...
88-
await autoRetryOnRateLimitError(() => client.v1.tweet('20'));
88+
await autoRetryOnRateLimitError(() => client.v2.tweet('20'));
8989
```
9090

9191
## Special case of paginators

0 commit comments

Comments
 (0)