Created
February 12, 2011 21:22
-
-
Save brntbeer/824140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'net/http' | |
require 'json' | |
uri = URI.parse("http://fluttrly.com/bouverdafs") #=> should be a valid task ID | |
http = Net::HTTP.new(uri.host, uri.port) | |
response = http.request(Net::HTTP::Get.new(uri.request_uri)) | |
# Use the get response above to get an auth token and cookie | |
auth_token = $1 if response.body =~ /"authenticity_token".*value="(.+)"/ or nil | |
raise "No authenticity token found :(" if auth_token.nil? | |
#COOKIE COOKIE COOKIE COOKIE COOKIE COOKIE | |
cookie = response['set-cookie'].split('; ')[0] | |
uri = URI.parse('http://fluttrly.com/tasks') | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Put.new(uri.request_uri) | |
params = JSON.generate("completed" => "true", "authenticity_token" => auth_token) | |
request["Cookie"] = cookie | |
##THEN WHAT??????????????? | |
#maybe? | |
response = http.request_put("/1135", params) | |
#results in a 422, and im not even using the request["Cookie"] at all, just sending | |
# auth_token and the completed => true field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment