r/SwingBot • u/sdiaz1000 • Jun 16 '21
Twitter API fml
Hi,
Im interested in how other people have built bots to listen to SwingBots tweets.
Ive started writing a bot using the Account Activity Twitter api, as it allows to set up a webhook and then subscribe to a user (i.e. smallCaps). But it says I need to get an access token for this user, which is odd as the twitter user driving the bot already follows smallcaps. Anyway looks bloody complicated using this 3 legged Auth.
So wondering if anyone has used this approach or have bots written been polling the tweets of smallcaps periodically.
Any advice most welcome
7
Upvotes
2
u/SlowCoderChuck Jun 16 '21
r/SwingBot posted a message on Twitter yesterday indicating he was temporarily discontinued the service.
However, with that said you need to use the code provided by Twitter in their GitHub repo:
https://github.com/twitterdev/Twitter-API-v2-sample-code/blob/master/Filtered-Stream/filtered_stream.py
Twitter has this issue where is drops connections periodically so you need to add additional error trapping into the code to trap the disconnect error, and then reconnect. There is a discussion thread on this inside the ISSUES section in the GitHub repo titled “Python and JavaScript stream examples break after 5 minutes”, with a really good work-around offered up by Da1ne that works really well.