08-25-2015 09:09
08-25-2015 09:09
I've been reading the docs over at https://dev.fitbit.com/docs/devices/ and using the library available at https://github.com/whazzmaster/fitgem.
I'm trying to set an alarm for "13:00-04:00"
The response I get back is:
301
Net::HTTPMovedPermanently
server: nginx
x-ua-compatible: IE=edge,chrome=1
location: http://api.fitbit.com/1/user/-/devices/tracker/alarms.json
connection: close, close
content-length: 0
date: Tue, 25 Aug 2015 15:56:56 GMT
x-frame-options: SAMEORIGINThe odd thing here I find is that the redirected URL does NOT have a tracker ID in it
My post body:
{
"enabled": "true",
"time": "14:00-04:00",
"recurring": "false",
"weekDays": [
]
}For the booleans, I've tried both "true" and true.
Modified from the original API:
def add_alarm(opts)
device_id = opts[:device_id]
post("/1/user/#{@user_id}/devices/tracker/#{device_id}/alarms.json", opts)
end
Best Answer08-25-2015 11:16
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
08-25-2015 11:16
You need to use HTTPS. https://api.fitbit.com
Best Answer08-25-2015 11:55
08-25-2015 11:55
From what I can tell, I am using HTTPS:
def consumer
@consumer ||= OAuth::Consumer.new(@consumer_key, @consumer_secret, {
:site => 'https://api.fitbit.com',
:authorize_url => 'https://www.fitbit.com/oauth/authorize',
:proxy => @proxy
})
end
def access_token
@access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)
endThe request is made using the access_token. If I understand everything here, my requests are being made over HTTPS.
I'm starting to feel like I need to reimplement the entire library and start with OAuth, but I wanted to see if this is a quick fix first before I do that.
Best Answer