Parsing Multiple Accounts and their Posts - Help

api

#1

To start, I would be lying if I said that I wasn’t a newbie or that I was experienced, so forgive me if something is overlooked or blatantly obvious.

I’m on Twitch quite a lot and have become a mod in multiple channels. A specific channel wants a bot for memes, and here is where Twitter comes in: I was wondering how I would select a Twitter account, choose one of their posts at random, and then post the tweet’s text with a direct link. Does anyone have any ideas? Thanks for reading!


#2

Depends what library / language you want to code in, but have a look at: https://dev.twitter.com/rest/reference/get/statuses/user_timeline

Once you have a set of twitter accounts you’re interested in, you can either use user_timeline to retrieve a number of recent tweets from each user and pick one at random, or cache tweets and then pick randomly later. You can periodically run user_timeline with since_id to get fresh tweets: https://dev.twitter.com/rest/public/timelines

Tweet text will be in the status object you get back, and for direct links to tweets the url is always https://twitter.com/[screen_name]/status/[tweet id] (user screen name will be in the user object in the tweet)

Or alternatively, you can add all the accounts you’re interested in to a list, and use https://dev.twitter.com/rest/reference/get/lists/statuses in the same way as user_timeline - you’ll get recent tweets from all the accounts on a list.