Skip to content

Instantly share code, notes, and snippets.

@rtanglao
Created September 20, 2009 05:13
Show Gist options
  • Save rtanglao/189724 to your computer and use it in GitHub Desktop.
Save rtanglao/189724 to your computer and use it in GitHub Desktop.
getReply.rb
require 'json'
require 'net/http'
require 'pp'
def getResponse(url)
http = Net::HTTP.new("api.getsatisfaction.com",80)
url = "/" + url
resp, data = http.get(url, nil)
if resp.code != "200"
puts "Error: #{resp.code}"
return ""
end
result = JSON.parse(data)
return result
end
topics = getResponse("companies/mozilla_messaging/topics.json?sort=recently_active&page=1&limit=1")
get_reply_str = "topics/" + topics["data"][0]["slug"] + "/replies.json?sort=recently_created&page=1&limit=1"
print "get_reply_str:", get_reply_str, "\n"
replies = getResponse(get_reply_str)
print "Author of reply 0:", replies["data"][0]["author"]["name"], "\n"
pp replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment