ttezel / twit

Twitter API Client for node (REST & Streaming API)
4.32k stars 573 forks source link

Support for: users/timelines/reverse_chronological #577

Open lcpichette opened 1 year ago

lcpichette commented 1 year ago

As the title suggests, I'm looking to see if this package supports the home timeline (Reverse Chronological) endpoint. This is a pretty important endpoint as it replicates the homepage query on Twitter.


UPDATE: I'm now hoping an example for this will be added to the README to help other developers. Better yet, if docs could be added that list every support endpoint (as they don't match with twitter's api endpoints).

Note: My developer account has elevated access, not sure if this works without it.

UPDATE

WORKS:

api.get('/timeline', async (req, res) => {
    TwitterAPI.get('statuses/home_timeline', { count: 50 }, (err, data, response) => {
        res.send(data);
    });
});

Previous Attempts

DOTE NOT WORK (Data is now an empty array) :

api.get('/timeline', async (req, res) => {
    TwitterAPI.get('statuses/user_timeline', { screen_name: '<MyDeveloperAccountUsername>', count: 50 }, (err, data, res) => {
        console.log(err);
        console.log(data);
    });
});

I would think that since I see tweets on my homepage, the array shouldn't be empty.

DOES NOT WORK (prints undefined and nothing, in that order):

TwitterAPI.get('users/timelines/reverse_chronological', {}, (err, data, res) => {
        console.log(err);
        console.log(data);
    });

DOES NOT WORK (prints undefined and nothing, in that order; replace <developeraccountuserid> with my developer account's user id):

api.get('/timeline', async (req, res) => {
    TwitterAPI.get('users/<developeraccountuserid>/timelines/reverse_chronological', { count: 50 }, (err, data, res) => {
        console.log(err);
        console.log(data);
    });
});

Using a different query

WORKS (successfully sends accurate data back):

const q = req.params['q'] || 'banana';
    TwitterAPI.get('search/tweets', { q: q, count: 50 }, function(err, data, response) {
        res.send(data);
    });