Permalink
Browse files

example to list followers and friends sorted by followers count

  • Loading branch information...
1 parent 2d1f7ca commit fb57b27e8a48abcc82810fe476413e8b506cebe6 @danicuki danicuki committed with Jul 1, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 examples/friends_followers_rank.rb
View
14 examples/friends_followers_rank.rb
@@ -0,0 +1,14 @@
+require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
+require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
+require 'pp'
+
+config = ConfigStore.new("#{ENV['HOME']}/.twitter")
+
+httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
+base = Twitter::Base.new(httpauth)
+
+puts "Friends List, sorted by followers"
+base.friends.sort {|a,b| a.followers_count <=> b.followers_count}.reverse.each {|f| puts "#{f.name} (@#{f.screen_name}) - #{f.followers_count}"}
+
+puts "\n\nFollowers List, sorted by followers"
+base.followers.sort {|a,b| a.followers_count <=> b.followers_count}.reverse.each {|f| puts "#{f.name} (@#{f.screen_name}) - #{f.followers_count}"}

0 comments on commit fb57b27

Please sign in to comment.