Last active
September 27, 2016 13:20
-
-
Save jonathanccalixto/0d085bfb227158c4b725c0fe79ec941e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 '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