Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'httparty'
- require 'activesupport'
- require 'pp'
- # EDIT THESE VALUES
- uname = ""
- pass = ""
- threshold = 1.week.ago
- class Twitter
- include HTTParty
- base_uri 'twitter.com'
- def initialize(u, p)
- @auth = {:username => u, :password => p}
- end
- def friends(page = 1)
- self.class.get("/friends/ids.json?page=#{page}", {:basic_auth => @auth})
- end
- def friend(id)
- self.class.get("/users/show/#{id}.json", {:basic_auth => @auth})
- end
- def unfollow(id)
- self.class.post("/friendships/destroy/#{id}.json", {:basic_auth => @auth})
- end
- end
- twitter = Twitter.new(uname,pass)
- friends = twitter.friends
- friends.each do |id|
- friend = twitter.friend(id)
- last_updated_at = DateTime.parse(friend["status"]["created_at"])
- if last_updated_at < threshold
- twitter.unfollow(id)
- end
- end
Add Comment
Please, Sign In to add comment