Skip to content

Instantly share code, notes, and snippets.

@DRMacIver
Created June 12, 2009 13:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
require "rubygems"
require "json"
require "httparty"
# Ruby script for fetching the "liked" history of a reddit user as json
module Reddit
include HTTParty
base_uri "http://reddit.com"
format :json
def self.liked(user)
results = []
after=nil
new_results = nil
while !(new_results = get("/user/#{user}/liked/.json", :query => {"after" => after})["data"]["children"]).empty?
results += new_results
last = new_results[-1]
after = last["kind"] + "_" + last["data"]["id"]
end
results
end
end
if $0 == __FILE__
puts Reddit.liked(ARGV[0].strip).to_json
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment