File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ const readOnlyClient = twitterClient.readOnly;
5858
5959// Play with the built in methods
6060const 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!
6363await twitterClient .v1 .uploadMedia (' ./big-buck-bunny.mp4' );
6464```
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ import { ApiResponseError } from 'twitter-api-v2';
4747
4848try {
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
You can’t perform that action at this time.
0 commit comments