I am working on a Twitter bot based on Elon Musk tweets, retrieving his user_timeline() every 1s, I have tested it on other users tweets (users with lower followers) and it works just fine, however for Elon's after a few of correct retrievals it crashes, is that an API issue, or is it something related to Request Limits, please let me know if u have any idea how why that is happening cuz I've been struggling for the past few hours? Thank you for your response.
Related
I have a twitter bot that tweets every hour, but I think it would be cool to make it so it tweets from a separate set of tweets or more frequently to a twitter circle, a smaller group of people which I set manually, but I'm not sure if any existing twitter api has that kind of functionality. Is this possible?
I haven't tried anything but I've been scouring the documentation for a while now, I just don't know where to even start in solving this problem.
I'm quite a novice, so please excuse my ignorance.
I've created a developer account on my personal Twitter account and my end goal is to have another account occasionally tweet something. I'm using tweepy and have successfully managed to tweet something, albeit from my account.
Twitter developer accounts can get their API key and secret, as well as an Access key and secret. What I'm trying to figure out is how to get my bot account's keys to have it tweet instead of my account.
After reading countless pages online as well as the docs, there seems to be a way to get auth another user through three-legged auth and pin-based auth, which seems like the correct route to my goal.
However, I have no idea where to go from here. The three-legged auth page asks for various required fields, of which I have no idea what to fill with (Callback URLs and Website URL). Moreover, the docs describe the process as one that needs to be initiated by the dev account, and I have no idea how to initiate that process at all.
Any help or guidance on what to do? My tweepy script is fully finished and just needs to be hooked up to the Twitter API.
Thanks.
EDIT & SOLUTION (03/18/2021):
Thanks to the comment by Sim leading to the article, I was able to derive a python script using Tweepy to authorize the bot using pin-based auth, found here. I'd give the article a read regardless, but once it starts telling you to create .js and .json files, stop there and use my script. That's what worked for me.
Found a solution that worked for me, I think this is what you need. https://dev.to/stratospher/many-bot-accounts-using-1-twitter-developer-account-17ff
I'm working on a bot that does jobs for Twitter users. They're supposed to request help by mentioning my bot like "#bot" with any other options in the text, optional.
Problem is, Twitter seems to consider directly #'ing someone in a new standalone tweet like "#jake hey" and replying to a tweet that user #jake made, with "hey" to be the exact same thing. If I check the full_text field for each status on tweepy, they both appear as "#jake hey". My bot needs a user supplied video to do its job. So if my bot were to reply to someone with a finished job, someone could reply to my bot with a video as a reaction to it, perhaps a video where someone says "Thank you!", my bot would confuse that as someone trying to request it to analyze that video for it. I need to prevent this so I don't reply to that user who didn't actually want to submit the video to my bot. I can't seem to find a way to differentiate between these two tweet examples, they seem to be the same under the hood. I hope I explained it soundly enough. Any ideas what I can do?
Okay, so basically I'm trying to write a program that would go through my twitter favorite history and find pieces of media from them and then download them. I actually have a working model in Python using Tweepy that works it's just it only gets the tweets in order of when they were created. See, the thing is I don't want to download my whole favorite history every time, just up to the point of the last mass download, so at first, I set it up to stop when the tweets reached a certain date. Every time I downloaded I would record the date, but then I realized that sometimes I favorite tweets that are from a while ago, before the cut off date, but is still new to my favorites history. So I decided to try something else, I would record the tweet ID of the first tweet in the list from the last time I downloaded and then set it to stop there, and this would work fine if the api.favorites() returned it in the order it appears on your profile, but instead it auto sorts them by date, so if I fav a post form 2010, I would have to cycle threw all the back to 2010 before it would appear on one of my returned pages. When I looked threw the docs I found a little bit on sorting, but nothing on sorting the Fav Hist by when you faved the tweet. And the thing is I know it stores the order that you liked the tweets in, since that's how it displays it on your profile, even if it is just a table that they append to every time, it still works. I know I'm writing this program in python, but I'm good enough with Java and JavaScript to understand the guts of the API, it's how I got this far. Anyway if you have some suggestions or now how to do it please let me know, any help is appreciated! If all else fails I'll try using Selenium to go through my Twitter Favs from a user perspective...
I had the same issue and I found that you can't do this with the regular Twitter API. They have an enterprise API, which requires payment to access, and that will give you the time a tweet was favorited but it doesn't look cheap so it's probably not worth it.
I'm writing a simple Twitter bot in Python and was wondering if anybody could answer and explain the question for me.
I'm able to make Tweets, but I haven't had the bot retweet anyone yet. I'm afraid of tweeting a user's tweet multiple times. I plan to have my bot just run based on Windows Scheduled Tasks, so when the script is run (for example) the 3rd time, how do I get it so the script/bot doesn't retweet a tweet again?
To clarify my question:
Say that someone tweeted at 5:59pm "#computer". Now my twitter bot is supposed to retweet anything containing #computer. Say that when the bot runs at 6:03pm it finds that tweet and retweets it. But then when the bot runs again at 6:09pm it retweets that same tweet again. How do I make sure that it doesn't retweet duplicates?
Should I create a separate text file and add in the IDs of the tweets and read through them every time the bot runs? I haven't been able to find any answers regarding this and don't know an efficient way of checking.
You should store somewhere the timestamp of the latest tweet processed, that way you won't go throught the same tweets twice, hence not retweeting a tweet twice.
This should also make tweet processing faster (because you only process each tweet once).
I wrote a twitter bot in python a few months ago and this link helped a lot. I also used this github repo which although is in Ruby, was quite helpful for logic flow. This repo uses a similar approach to what you mentioned, creating a local datastore of previous retweets to compare against each tweet.
This is how I did it. I grabbed the list of things to retweet and a list of my feed. I cut the lists down to only posts within the past 24 hours. Then for each item in retweetable I check to see if it's in my feed list. If not I post RT #user retweet content.
I also wrote a function to chop the str down to 140 chars (137 + '...')
E.G.
TO_RT = 'a post to post'
MYTWT = ('old post', 'other old post')
if TO_RT not in MYTWT
Tweet(TO_RT)
Twitter is set such that you can't retweet the same thing more than once. So if your bot gets such a tweet, it will be redirected to an Error 403 page by the API. You can test this policy by reducing the time between each run by the script to about a minute; this will generate the Error 403 link as the current feed of tweets remains unchanged.