Skip to content

Instantly share code, notes, and snippets.

@jonathanccalixto
Last active September 27, 2016 13:20
Show Gist options
  • Select an option

  • Save jonathanccalixto/0d085bfb227158c4b725c0fe79ec941e to your computer and use it in GitHub Desktop.

Select an option

Save jonathanccalixto/0d085bfb227158c4b725c0fe79ec941e to your computer and use it in GitHub Desktop.
require 'active_support/all'
class FreeleticsLogin
def self.log(*args)
new(*args).log
end
def initialize(email, password)
self.login_url = 'https://www.freeletics.com/api/user/v1/auth/password/login'
self.email = email
self.password = password
self.headers = {
'Host:' => 'www.freeletics.com',
'Connection:' => 'keep-alive',
'Content-Length:' => '71',
'Accept:' => 'application/json, text/plain, */*',
'Origin:' => 'https://www.freeletics.com',
'Accept-Language:' => 'pt',
'User-Agent:' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36',
'Content-Type:' => 'application/json;charset=UTF-8',
'DNT:' => '1',
'Referer:' => 'https://www.freeletics.com/pt/login',
'Accept-Encoding:' => 'gzip, deflate, br',
'Cookie:' => 'country_code=BR; PRUM_EPISODES=s=1474572369951&r=https%3A//www.freeletics.com/pt/bodyweight/users/2768424/feed'
}
end
def log
JSON.parse(`curl -s '#{login_url}' #{ headers.map { |k, v| "-H '#{k} #{v}'" }.join(" ")} --data-binary '{"login":{"email":"#{email}","password":"#{password}"}}' --compressed`)
end
protected
attr_accessor :login_url, :email, :password, :headers
end
puts "Email:"
email = gets.chomp
puts "Password:"
password = gets.chomp
p FreeleticsLogin.log email, password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment