Skip to content

Instantly share code, notes, and snippets.

@mperham
Created July 16, 2009 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mperham/148665 to your computer and use it in GitHub Desktop.
Save mperham/148665 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'cgi'
require 'json'
# The Bossman is in charge, mon.
class Bossman
def search(terms='iphone 3gs')
query = CGI::escape(terms)
path = "/ysearch/news/v1/#{query}"
query = "appid=topsecret"
resp = Net::HTTP.start 'boss.yahooapis.com' do |http|
http.get("#{path}?#{query}")
end
JSON.parse(resp.body) if resp.code.to_i == 200
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment