Skip to content

Instantly share code, notes, and snippets.

@affix
Created August 3, 2014 01:46
Show Gist options
  • Select an option

  • Save affix/e0527793a8a46a8611d9 to your computer and use it in GitHub Desktop.

Select an option

Save affix/e0527793a8a46a8611d9 to your computer and use it in GitHub Desktop.
# Call Of Duty API Login
# Written by Keiran Smith <affix_at_affix_dot_me>
# (c) 2014 Keiran Smith
# This is not licensed via Activision or any other
# official call of duty publishers
# If I reveive a DMCA I will remove.
# Licenced under GNU/GPLv3
require 'uri'
require 'net/http'
require 'net/https'
require 'json'
data = { "email" => "EMAIL_ADDR", "password" => "PASSWORD"}
uri = URI.parse("https://api.live-ca.callofduty.com/loginclient")
@headers = {
"User-Agent" => "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/538.46 (KHTML, like Gecko) Mobile/12A4331d",
"Origin" => "https://api.live-ca.callofduty.com",
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri.path)
req.set_form_data(data)
res = http.request(req)
variable = res.body.match("{\"User\":{\"accountList\":{\"account\":{\"activeState\":(.*),\"communityId\":\"(.*)\",\"countLoggedInUser\":0,\"email\":\"(.*)\",\"id\":(.*),\"isActive\":(.*),\"lastLoginDate\":\"(.*)\",\"parentEmail\":\"(.*)\",\"username\":\"(.*)\"}},\"addressLine1\":\"\",\"addressLine2\":\"\",\"answerList\":{\"answer\":{\"answerId\":(.*),\"answerText\":\"(.*)\",\"questionId\":(.*)}},\"birthdate\":\"(.*)\",\"city\":\"(.*)\"}}")
result = JSON.parse(variable[0])
# Output JSON in a pretty format
puts JSON.pretty_generate(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment