rhiever / TwitterFollowBot

A Python bot that automates several actions on Twitter, such as following users and favoriting tweets.
GNU General Public License v3.0
1.31k stars 447 forks source link

auto_unfollow_non_followers function killing oauth tokens #95

Closed MistaCrowley closed 8 years ago

MistaCrowley commented 8 years ago

Seemingly randomly, when i try to run the auto_unfollow_non_followers function, I get the 'invalid or expired token' 'code 89' message and i have to manually log into my app account and regenerate my oauth tokens just to run the bot again. I waited a day, made no requests or pulls, and tried running the function and it still broke my tokens. I'm getting no message back from twitter regarding api pulls, my account is still active and my app has not been suspended, just the oauth access token has been deleted. Do you have any idea what's going on? Is there an automatic method of acquiring oauth tokens that can be used instead of manually generating a new one and copypasting it to the config file?

MistaCrowley commented 8 years ago

The error doesn't occur when I use sync_follows(), so my guess is the error occurs when the script tries to pull user ids from twitter.

MistaCrowley commented 8 years ago

I believe I solved the problem, it seems to have been a validation error on my end when I first gave the app access to my account. My apologies.

MistaCrowley commented 8 years ago

Woah ok somehow the problem didn't occur for an entire two days, until tonight. Same problem, still persistent, only happens when I try to unfollow, When my bot runs it unfollows a small, arbitrary number of people before throwing the error "Invalid or expired token, code 89, status 401". At which point my bot is revoked access of my account (without my permission) and my access key is deleted. From there I need to manually reverify and repull another access key just to get it up and working again, until it randomly crashes again. Any ideas?

dhilowitz commented 8 years ago

Same here.

rhiever commented 8 years ago

I haven't tinkered around with the Twitter API in a long while now, but I'm betting it's the API admins automatically catching unwanted "bot-like" behavior and suspending your token.

Your best bet may to be to add longer pauses in between the bot actions. IIRC FOLLOW_BACKOFF_MIN_SECONDS etc. in the config file should affect all actions, including unfollows.

Let's please redirect this chat to the repo gitter channel: https://gitter.im/rhiever/TwitterFollowBot