Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created January 13, 2016 11:08
Show Gist options
  • Save tommorris/423f9d925ac8fbd5ad9d to your computer and use it in GitHub Desktop.
Save tommorris/423f9d925ac8fbd5ad9d to your computer and use it in GitHub Desktop.
import twitter
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in xrange(0, len(l), n):
yield l[i:i+n]
def put_friends_on_list(oauth_creds, username, list_name):
t = Twitter(auth=OAuth(*oauth_creds)
res = t.friends.ids()
for chunk in chunks(res['ids'], 100):
t.lists.members.create_all(owner_screen_name=username, slug=list_name, user_id=','.join([str(x) for x in chunk]))
if __name__ == '__main__':
oauth_creds = ("","","","")
username = ""
list_name = ""
put_friends_on_list(oauth_creds, username, list_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment