Created
September 20, 2009 05:13
-
-
Save rtanglao/189724 to your computer and use it in GitHub Desktop.
getReply.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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