Show
Ignore:
Timestamp:
07/03/08 11:08:39 (6 months ago)
Author:
hsbt
Message:

fetch over 101 users.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/misc/twitter_remove_friends/twitter_remove_friends_json.rb

    r15076 r15079  
    1717followers = [] 
    1818begin 
    19         doc = JSON.parse(open(TWITTER_API + "statuses/friends.json", :http_basic_authentication => [twitter_account[:username], twitter_account[:password]]).read) 
    20         yaml = YAML.load(Pathname.new(ARGV[0]).expand_path.read) 
     19        page = 1 
     20        yaml = YAML.load(Pathname.new(ARGV[0] || "defaults.yaml").expand_path.read) 
    2121 
    22         doc.each do |user| 
    23                 duration = Time.now - Time.parse(user["status"]["created_at"]) 
    24                 if duration > yaml["duration"].to_i * 24 * 60 * 60 
    25                         followers << user["screen_name"] 
     22        loop do 
     23                json = JSON.parse(open(TWITTER_API + "statuses/friends.json?page=#{page}", :http_basic_authentication => [twitter_account[:username], twitter_account[:password]]).read) 
     24                break if json.empty? 
     25                 
     26                json.each do |user| 
     27                        duration = Time.now - Time.parse(user["status"]["created_at"]) 
     28                        if duration > yaml["duration"].to_i * 24 * 60 * 60 
     29                                followers << user["screen_name"] 
     30                        end 
    2631                end 
     32                 
     33                page += 1 
     34                sleep(5) 
    2735        end 
    2836