Created
March 10, 2013 01:47
-
-
Save bbck/5126718 to your computer and use it in GitHub Desktop.
Guild Wars 2 trading post auth test.
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 'faraday' | |
conn = Faraday.new(:url => "https://account.guildwars2.com") do |faraday| | |
faraday.request :url_encoded | |
faraday.response :logger | |
faraday.adapter Faraday.default_adapter | |
end | |
response = conn.post do |req| | |
req.url "/login" | |
#req.headers["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" | |
#req.headers["Connection"] = "keep-alive" | |
#req.headers["Accept-Encoding"] = "deflate" | |
#req.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1" | |
#req.headers["Accept-Language"] = "en;q=0.5" | |
req.headers["Referer"] = "https://account.guildwars2.com/login" | |
req.body = { email: "user@example.com", password: "secret" } | |
end | |
cookie = response.headers["set-cookie"].match /(\w{8}-\w{4}-\w{4}-\w{4}-\w{12})/ | |
conn = Faraday.new(:url => "https://tradingpost-live.ncplatform.net") do |faraday| | |
faraday.request :url_encoded | |
faraday.response :logger | |
faraday.adapter Faraday.default_adapter | |
end | |
response = conn.get do |req| | |
req.url "/ws/search.json?text=&levelmin=0&levelmax=80&offset=0" | |
req.headers["Cookie"] = "s=#{cookie}" | |
end | |
puts response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment