def get_oauth():
oauth = OAuth1(CONSUMER_KEY,
client_secret=CONSUMER_SECRET,
resource_owner_key=OAUTH_TOKEN,
resource_owner_secret=OAUTH_TOKEN_SECRET)
return oauth
while 1 == 1:
if __name__ == "__main__":
oauth = get_oauth()
for i in xrange(8):
# get favorites tweet data (maximum 200 per call, "count=200"
r = requests.get(url="https://api.twitter.com/1.1/favorites/list.json?count=200", auth=oauth)
# store fav_ids in a list
with open("Output.txt", "w") as text_file:
text_file.write(str(r))
text_file.write("Done!")
fav_ids = [fav['id'] for fav in r.json()]
# loop through each fav id and remove from twitter
for fav in fav_ids :
data = {'id' : fav}
response = requests.post(url="https://api.twitter.com/1.1/favorites/destroy.json",auth=oauth,data=data)
print i
This file worked for the first three thousand favorites (which would be the equivalent of it running twice then stopped. The i still prints out but no favorites come back. I thought it was a day rate limit but it wasn’t.
Is it just that the Twitter API won’t return past a certain date/volume of favorites?