I recently got a FitBit One (review forthcoming), and one of the big reasons I got it was their open API. Basically, the FitBit will sync over Bluetooth 4.0 (Lower Power) when it sees it’s Dongle, or if you have an iPhone/Android phone, it can sync to that in the background. That data syncs up to the FitBit website, at which point you can pull the data back down using their API… at least, that was my hope.
After playing with things for a few days, I finally got this working, and my steps information will now dynamically update. I still am not sure how I’ll correct for issues like being out of town, etc… but I’ll figure something out.
Anyway, since no one seems to have detailed how to do this with PHP, I thought I would here. This is all assuming you’ll only be grabbing your own info.
First, go to http://dev.fitbit.com, and register your app. Most of the info you put in doesn’t matter, except you do want to be honest. So obviously don’t lie.
After that, you’ll get two pieces of info, the Consumer Key, and Consumer Secret. Okay, now go grab the very useful PHP Fitbit oAuth wrapper here. Drop that in a directory, and in that same directory, create your PHP script that you’ll be using.
At this point, the code below is all you need to grab say, Steps from a date (specified in YYYY-MM-DD). To find out how to grab other info, you’ll need to look through the oAuth wrapper.
$day = "2013-12-01";
$fitbit = new FitBitPHP('CONSUMER_KEY','CONSUMER_SECRET');
$xml = $fitbit->getTimeSeries(steps,"$day",'1d');
$xml = $xml;
$datetime = $xml->dateTime;
$steps = $xml->value;
The bits you need to change are the CONSUMER_KEY, CONSUMER_SECRET, and USER_ID. Once you have all of that, run the script either via a web browser, or via the command line, and you should get a simple step number back for the day in question. You may also get back an unauthorized notice, in which case you may need to adjust the privacy settings on your activity via the Fitbit website interface.