feat: add sendTweet with media upload support#193
Open
Faareoh wants to merge 4 commits into
Open
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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