Posted By

pdxmph on 08/02/10


Tagged

ruby twitter Google-Charts


Versions (?)

Chart Total Proportion of Recent Tweets by Friend


 / Published in: Ruby
 

  1. #!/usr/bin/env ruby
  2.  
  3. require "rubygems"
  4. require "twitter"
  5. require "active_support"
  6. require "google_chart"
  7.  
  8.  
  9. twitter_user = ""
  10. twitter_pass = ""
  11.  
  12. httpauth = Twitter::HTTPAuth.new(twitter_user, twitter_pass)
  13. client = Twitter::Base.new(httpauth)
  14.  
  15. totals = {}
  16.  
  17. client.friends_timeline(:count => 200).each do |t|
  18. user = t.user.screen_name
  19. if !totals.has_key? user
  20. totals[user] = 1
  21. else
  22. totals[user] +=1
  23. end
  24. end
  25.  
  26. pc = GoogleChart::PieChart.new('500x200', "Total Proportion of Recent Tweets", false)
  27.  
  28. totals.each do |key,val|
  29. pc.data key, val
  30. end
  31.  
  32. puts pc.to_url

Report this snippet  

You need to login to post a comment.