Skip to content

Instantly share code, notes, and snippets.

@zonoise
Created February 2, 2012 02:38
Show Gist options
  • Save zonoise/1721059 to your computer and use it in GitHub Desktop.
Save zonoise/1721059 to your computer and use it in GitHub Desktop.
twitter list members to Redis
def get_lists(key,screen_name,list_slug)
redis = Redis.new
#max listmember 500 and per request 20 member
if 25 >= Twitter.rate_limit_status.remaining_hits
return false
end
next_cursor='-1'
while next_cursor != 0 do
members = Twitter.list_members(screen_name,list_slug,{'cursor'=>next_cursor,'skip_status'=>true})
next_cursor = members['next_cursor']
#we need only id and screen_name
members['users'].each do |member|
redis.rpush(key,{'id'=>member['id'],'screen_name'=> member['screen_name']}.to_json)
end
end
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment