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

Added ability to post media in tweets #430

Closed Rishikant181 closed 5 months ago

Rishikant181 commented 5 months ago

Media items can now be posted in tweets, by an optional second parameter while calling the Rettiwt.tweet.tweet method. The following example demonstrates this:

import { Rettiwt } from 'rettiwt-api';

// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });

// Posting a tweet, containing an image, to twitter
rettiwt.tweet.tweet('What a nice image!', [{ path: '<path_to_media>' }])
.then(res => {
    console.log(res);
})
.catch(err => {
    console.log(err);
});

Where,

The optional second parameter takes in a list of media items, therefore multiple media items can be posted in a single tweet.