-1

I am writing an Google App Engine application that adds a python list of twitter screen names to a list on twitter. I am using Twython as my Twitter API wrapper. I am able to add some of the screen names from my Python list but not all of them. It returns the error,

TwythonError: Twitter API returned a 403 (Forbidden), You aren't allowed to add members to this list

I believe one of the reason for this is that a member from my Python list has be removed by Twitter.

Now I would like to skip that user, and continue with the list. The problem being that I have no clue of the point at which it breaks. My code is as follows....

for member in new_member_list:
    twitter.add_list_member(slug = twitterlist, owner_screen_name = my_screen_name,
    screen_name = member)

Much appreciate your help.

Thank you

1 Answers1

0

Wrap it in a try/except I don't use twython but this seems to be the error:

from twython import TwythonAuthError

for member in new_member_list:
    try:
        twitter.add_list_member(slug = twitterlist, owner_screen_name = my_screen_name,screen_name = member)
    except TwythonAuthError: # catch auth exception 
           pass

The exceptions are listed here

Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321
  • I very much appreciate your reply. Thank you. However, there is a problem with this method. If there is a bad user I cannot add to my list on Twitter, my code breaks at this point. What your suggested answer does is that it handles the error but it does not add more users to my twitter list from my python list anymore. – user3622138 Aug 13 '14 at 12:13