Rishikant181 / Rettiwt-API

A CLI tool and an API for fetching data from Twitter for free!
https://rishikant181.github.io/Rettiwt-API/
MIT License
305 stars 31 forks source link

Replying to a tweet? #448

Closed smaldd14 closed 4 months ago

smaldd14 commented 4 months ago

Is there a way to reply to a user's tweet? If you have a given tweet ID is there a way to reply to that tweet?

Or is there any way that can be a feature request?

Rishikant181 commented 4 months ago

Unfortunately, currently there is now way to reply to a tweet.

But it can be added. I'll open up an issue for tracking this feature request.

Edit 1: Here is the issue #449

IbrahimAbdi1 commented 4 months ago

Unfortunately, currently there is now way to reply to a tweet.

But it can be added. I'll open up an issue for tracking this feature request.

Edit 1: Here is the issue #449

I made a code snippet of that replies to a users tweet given tweet id. could u please give me the request object u make when uploading a tweet with media? Im bad at programming and the docs are too confusing for me to read. You'll understand what i mean by request object by looking at the snippet

replace "enter id here" with tweet id

` const rettiwt = new Rettiwt({ apiKey: apikey});

authorization = rettiwt.auth.cred.authToken; csrf = rettiwt.auth.cred.csrfToken; cookie = rettiwt.auth.cred.cookies;

const requestPayload = { variables: { tweet_text: "I replied ez", reply: { in_reply_to_tweet_id: "enter id here", exclude_reply_user_ids: [], }, dark_request: false, media: { media_entities: [], possibly_sensitive: false, }, semantic_annotation_ids: [], }, features: { c9s_tweet_anatomy_moderator_badge_enabled: true, tweetypie_unmention_optimization_enabled: true, responsive_web_edit_tweet_api_enabled: true, graphql_is_translatable_rweb_tweet_is_translatable_enabled: true, view_counts_everywhere_api_enabled: true, longform_notetweets_consumption_enabled: true, responsive_web_twitter_article_tweet_consumption_enabled: true, tweet_awards_web_tipping_enabled: false, longform_notetweets_rich_text_read_enabled: true, longform_notetweets_inline_media_enabled: true, rweb_video_timestamps_enabled: true, responsive_web_graphql_exclude_directive_enabled: true, verified_phone_label_enabled: false, freedom_of_speech_not_reach_fetch_enabled: true, standardized_nudges_misinfo: true, tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true, responsive_web_graphql_skip_user_profile_image_extensions_enabled: false, responsive_web_graphql_timeline_navigation_enabled: true, responsive_web_enhance_cards_enabled: false, }, queryId: "_BCvBRcat20zPDIAxmH5ag", };

const requestHeader = { method: 'POST', url: '/i/api/graphql/_BCvBRcat20zPDIAxmH5ag/CreateTweet', baseURL: 'https://twitter.com', headers: { 'Host': 'twitter.com', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0',

  'authorization': `Bearer ${authorization}`,
  'x-csrf-token': `${csrf}`,  
  'Connection': 'keep-alive',
  'Cookie': `${cookie}`, 
  'TE': 'trailers',
},
data: requestPayload,

};

axios(requestHeader) .then(response => { console.log('Response:', response.data); }) .catch(error => { console.error('Error:', error); });

`

Rishikant181 commented 4 months ago

@IbrahimAbdi1 Yeah this will do, but, these changes must first me made to Rettiwt-Core.

You see, the way this package works is Rettiwt-Core first generates the required request configuration based on the requested data. The returned configuration is then used by this package to make requests then filter out the gibberish data and return only the meaningful data.

The requestPayload which you provided in the snippet will be dynamically generated in Rettiwt-Core

If you are willing to work, you may add it to Rettiwt-Core, if not, I'll be stealing this snippet and adding it myself :P

Expect changes in the next feature update.

IbrahimAbdi1 commented 4 months ago

@IbrahimAbdi1 Yeah this will do, but, these changes must first me made to Rettiwt-Core.

You see, the way this package works is Rettiwt-Core first generates the required request configuration based on the requested data. The returned configuration is then used by this package to make requests then filter out the gibberish data and return only the meaningful data.

The requestPayload which you provided in the snippet will be dynamically generated in Rettiwt-Core

If you are willing to work, you may add it to Rettiwt-Core, if not, I'll be stealing this snippet and adding it myself :P

No please do it yourself lol. If u can implement replying with media that would be awesome

Rishikant181 commented 4 months ago

@IbrahimAbdi1 On it.

Thanks for the feedback!

IbrahimAbdi1 commented 4 months ago

@IbrahimAbdi1 On it.

Thanks for the feedback!

Oh if you can add the ability to send a bytearray for upload instead of media path that would be great.