- Timestamp:
- 10/13/08 20:59:05 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/misc/twitter_remove_friends/twitter_remove_friends_json.rb
r15139 r21250 2 2 3 3 require 'open-uri' 4 require 'net/http' 4 5 require 'yaml' 5 6 require 'pathname' … … 7 8 require 'pit' 8 9 require 'json' 10 11 Net::HTTP.version_1_2 9 12 10 13 TWITTER_API = URI('http://twitter.com/') … … 23 26 json = JSON.parse(open(TWITTER_API + "statuses/friends.json?page=#{page}", :http_basic_authentication => [twitter_account[:username], twitter_account[:password]]).read) 24 27 break if json.empty? 25 28 26 29 json.each do |user| 30 next if user["status"].nil? 27 31 duration = Time.now - Time.parse(user["status"]["created_at"]) 28 32 followers << user["screen_name"] if duration > yaml["duration"].to_i * 24 * 60 * 60 … … 36 40 37 41 followers.each do |name| 38 next if yaml["ignore"].include?(name) 39 open(TWITTER_API + "friendships/destroy/#{name}.xml", :http_basic_authentication => [twitter_account[:username], twitter_account[:password]]) 40 puts "#{name} is removed" 41 sleep(10) 42 req = Net::HTTP::Post.new( "/friendships/destroy/#{name}.json", '' ) 43 req.basic_auth twitter_account[:username], twitter_account[:password] 44 Net::HTTP.start( TWITTER_API.host ) do |http| 45 response = http.request(req) 46 puts "#{name} is removed." 47 end 48 sleep(15) 42 49 end 43 50 rescue => e
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)