The config file is located at ~/.config/nike/config is formated like a
regular yaml file:
access_token: xxxxxxx
deviceId: xxxxxxx
| require 'json' | |
| require 'date' | |
| data = JSON.parse(File.read("data.json")) | |
| days = [] | |
| data["daily"].each do |day| | |
| current = {} | |
| current["date"] = day["summary"]["startDate"] / 1000 | |
| current["fuel"] = day["summary"]["avgFuelPerDay"] | |
| current["steps"] = day["summary"]["steps"] | |
| current["activeTime"] = day["summary"]["activeTime"] | |
| days << current | |
| end | |
| File.open('daily.json', 'w') {|f| f.write(JSON.pretty_generate days)} |
| require 'json' | |
| require 'yaml' | |
| require 'net/http' | |
| config = YAML.load_file("#{ENV['HOME']}/.config/nike/config") | |
| start_date = '171212' | |
| end_date = '201212' | |
| fidelity = 24 | |
| headers = { | |
| 'Accept' => 'application/json', | |
| 'appid' => 'fuelband' | |
| } | |
| params = { | |
| 'access_token' => config["access_token"], | |
| 'deviceId' => config["deviceId"], | |
| 'endDate' => end_date, | |
| 'fidelity' => fidelity | |
| } | |
| uri = URI.parse("https://api.nike.com/v1.0/me/activities/summary/#{start_date}") | |
| uri.query = URI.encode_www_form(params) | |
| http = Net::HTTP.new(uri.host, uri.port) | |
| http.use_ssl = true | |
| http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
| request = Net::HTTP::Get.new(uri.request_uri) | |
| request['Accept'] = 'application/json' | |
| request['appid'] = 'fuelband' | |
| response = http.request(request) | |
| File.open('data.json', 'w') {|f| f.write(JSON.pretty_generate JSON.parse response.body) } |
| require 'json' | |
| require 'date' | |
| data = JSON.parse(File.read("data.json")) | |
| days = [] | |
| data["daily"].each do |day| | |
| current = {} | |
| current["date"] = day["summary"]["startDate"] / 1000 | |
| current["points"] = [] | |
| day["history"].map { |val| current["points"] << val["fuel"] } | |
| days << current | |
| end | |
| File.open('hourly_points.json', 'w') {|f| f.write(JSON.pretty_generate days)} |
Hello, did you figure out how to find the Device ID and Access Token in Charles?
It's not crashing for me but I also haven't been able to find them anywhere in the output.