feat: add sendTweet with media upload support#193
Conversation
Adds scraper.sendTweet() for posting tweets via the CreateTweet GraphQL mutation, including image/video media upload through the chunked upload API. - Add mutationEndpoints (CreateTweet queryId + URL) to api-data.ts - Implement uploadMedia() with chunked video upload + polling and simple image upload paths - Implement sendTweet() returning Tweet | null; injects __typename when absent from the CreateTweet API response to satisfy the parser - Add optional x-client-transaction-id generation to avoid 226 errors - Expose sendTweet on the Scraper class and export MediaData from _module.ts - Add unit + opt-in integration tests in tweet-mutations.test.ts
|
The |
Summary
src/api-data.ts— addsmutationEndpoints.CreateTweet(current queryId +x.comURL)src/tweets.ts— implementsuploadMedia()(chunked video + simple image) andsendTweet()returningTweet | nullsrc/scraper.ts— exposessendTweet()as a public method on theScraperclasssrc/_module.ts— exports the newMediaDatatypesrc/tweet-mutations.test.ts— unit tests + opt-in integration tests for the mutationKey details
CreateTweetGraphQL mutation (queryId: S1qcGUn68_U0lDKdMlYSGg) viaPOST x.com/i/api/graphql/…__typename: 'Tweet'on the response when absent (the CreateTweet API omits it) so the existing parser can handle itx-client-transaction-idwhen theexperimental.xClientTransactionIdoption is enabled, to avoid Twitter's 226 "looks automated" errorsMediaDataaccepts{ data: Buffer, mediaType: string }; videos use the chunked INIT/APPEND/FINALIZE flow with status pollingTest plan
npm test— all unit tests passTWITTER_*env vars and runnpx jest tweet-mutations --testNamePattern=integration