Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
Created March 1, 2010 22:29
Show Gist options
  • Select an option

  • Save lukeredpath/318890 to your computer and use it in GitHub Desktop.

Select an option

Save lukeredpath/318890 to your computer and use it in GitHub Desktop.
require 'rest_client'
require 'json'
require 'active_support/all'
def wiki(action, params={})
params.merge!(:action => action, :format => 'json')
headers = {"User-Agent" => "Ruby Wikipedia Client", "Accept" => "application/json"}
RestClient.get("http://en.wikipedia.org/w/api.php?#{params.to_query}", headers) do |response|
JSON.parse(response.body)
end
end
# wiki("opensearch", :search => "beat", :limit => 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment