Skip to content

Instantly share code, notes, and snippets.

@alvin2ye
Created October 26, 2009 02:34
Show Gist options
  • Save alvin2ye/218396 to your computer and use it in GitHub Desktop.
Save alvin2ye/218396 to your computer and use it in GitHub Desktop.
Delete a tweet on Twitter
copy from http://feeds.dzone.com/~r/snippets/ruby/~3/gdGhzZh5GGs/8233
headers = {
"User-Agent" => "Ruby v1.8",
"X-Twitter-Client" => "Ruby",
"X-Twitter-Client-Version" => "1.8"
}
path = "http://twitter.com/statuses/destroy/5157931577.xml"
url = URI.parse(path)
req = Net::HTTP::Post.new(url.path, headers)
req.basic_auth('drobertson', 'password')
req.delete(path)
response = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
Here's another variation:
Net::HTTP.start('twitter.com') do |http|
req = Net::HTTP::Delete.new(path, headers)
req.basic_auth('drobertson', 'password')
response = http.request(req)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment