在Ruby中跟随你的追随者
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Ruby中跟随你的追随者相关的知识,希望对你有一定的参考价值。
require 'twitter' # Check out the twitter gem docs for using oauth httpauth = Twitter::HTTPAuth.new("username", "password") base = Twitter::Base.new(httpauth) to_follow_ids = base.follower_ids - base.friend_ids unavailable_count = 0 to_follow_ids.each do |tfid| begin base.friendship_create(tfid, true) rescue Twitter::General # Twitter::General is raised for 403 errors # Which occur when you're trying to follow someone who's been banned by twitter base.block(tfid) rescue Twitter::Unavailable # Wait and try again if twitter's telling you to wait sleep 5 if unavailable_count < 3 retry unavailable_count += 1 end end end
以上是关于在Ruby中跟随你的追随者的主要内容,如果未能解决你的问题,请参考以下文章