PHPackages                             thesavior/fitbit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. thesavior/fitbit

ActiveLibrary

thesavior/fitbit
================

Fitbit library with OAuth

173167[2 PRs](https://github.com/TheSavior/fitbitphp/pulls)PHP

Since Sep 19Pushed 10y ago3 watchersCompare

[ Source](https://github.com/TheSavior/fitbitphp)[ Packagist](https://packagist.org/packages/thesavior/fitbit)[ RSS](/packages/thesavior-fitbit/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

FitbitPHP
---------

[](#fitbitphp)

Basic wrapper for OAuth-based [FitBit](http://fitbit.com) [REST API](http://dev.fitbit.com). Seek more information on API developments at [dev.fitbit.com](http://dev.fitbit.com). This library does **NOT** require the OAuth extension to be installed in PHP. This should work on any server with php &gt;= 5.4.

Library is in BETA as well as the API, so it could still be buggy. We're looking forward to update the library as API moves forward, doing best not to break backward compatibility. That being said, feel free to fork, add features and send pull request to us if you need more awesomness right now, we'll be happy to include them if well done.

**Current notes:**

- *Subscriptions*: Library has basic methods to add/delete subscriptions, unfortunately it's your headache to track the list and deploy server endpoints to receive notifications from Fitbit as well as register them at . See [Subscriptions-API](http://wiki.fitbit.com/display/API/Subscriptions-API) for more thoughts on that,
- *Unauthenticated calls*: Some methods of Fitbit API grant access to public resources without need for the complete OAuth workflow, `searchFoods` and `getActivities` are two good example of such endpoints. Nevertheless, this calls should be signed with Authentication header as usual, but access\_token parameter is omitted from signature base string. In terms of FitbitPHP, you can make such calls, but you shouldn't use `initSession` (so access\_token wouldn't be set) and should explicitly set the user to fetch resources from before the call (via `setUser`).

Installation
------------

[](#installation)

This package is installable with composer: "thesavior/fitbit": "dev-master"

Usage
-----

[](#usage)

First, as always don't forget to register your application at  and obtain consumer key and secret for your application.

Library itself handles whole OAuth application authorization workflow for you as well as session tracking between page views. This could be used further to provide 'Sign with Fitbit' like feature (look at next code sample) or just to authorize application to act with FitBit API on user's behalf.

Example snippet on frontend could look like:

```
