Skip to content

Instantly share code, notes, and snippets.

@wrburgess
Created January 22, 2012 14:51
Show Gist options
  • Save wrburgess/1657280 to your computer and use it in GitHub Desktop.
Save wrburgess/1657280 to your computer and use it in GitHub Desktop.
Twitter GET call on Sinatra
# app.rb
require 'sinatra'
require 'net/http'
require 'json'
url = 'http://search.twitter.com/search.json?q=shaq'
payload_raw = Net::HTTP.get_response(URI.parse(url)).body
payload_parsed = JSON.parse(payload_raw)
@results = payload_parsed['results']
# template.erb
<% @results.each do |value| %>
<%= value['from_user'] %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment