Skip to content

Instantly share code, notes, and snippets.

@mwunsch
Created December 30, 2009 20:30
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 mwunsch/266365 to your computer and use it in GitHub Desktop.
Save mwunsch/266365 to your computer and use it in GitHub Desktop.
status = Weary.get("http://twitter.com/statuses/user_timeline") do |r|
r.with = {:id => 'markwunsch'}
end
status.before_send do |request|
puts "Sending a request to #{request.uri}"
end
status.on_complete do |response|
if response.success?
puts response.body
else
puts "Something went wrong: #{response.code}: #{response.message}"
end
end
Weary.get "http://twitter.com/statuses/user_timeline" do |req|
req.follows = false
req.with = {:id => 'markwunsch'}
req.credentials = {:username => 'markwunsch', :password => 'secret'}
req.headers = {"User-Agent" => Weary::UserAgents["Safari 4.0.2 - Mac"]}
end
status.perform do |response|
puts "Request to #{response.url}, complete. Got a #{response.code}."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment