Download the PHP package brulath/fitbit-php-oauth2 without Composer

On this page you can find all versions of the php package brulath/fitbit-php-oauth2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fitbit-php-oauth2

Not maintained, archived.

Unofficial Fitbit Client Library for PHP using OAuth2

Wholesale borrows large portions of djchen/OAuth2-Fitbit (minor change to error checking and scope handling) and pavelrisenberg/fitbitphp.

Sets a fitbit-php-oauth2-state cookie during auth flow to prevent CSRF attacks. A session must be started beforehand.

Not guaranteed to work under any circumstances, but it's nice when it does.

Installation

To install, use composer:

Usage

Initialization

All below examples will assume a $fitbit is available. It currently is stateful, so you must set the correct token before using it to make a request.

Token Refreshing Warning

OAuth2 tokens expire; sometimes they expire very quickly. In order to avoid having to manually acquire an updated token from Fitbit, the library does so for you when it detects you attempting to perform an action on an expired token. The good news is that this means you can be lazy regarding keeping tokens fresh, but the less good news is that you need to be vigilant and grab the updated token when it changes.

There are two options for capturing token acquisitions:

Subscribe to a token-change event:

Check post-request for token changes

If you do not wish to use events for some reason, you can check for the token after every call you make to the API:

I'm lazy, so I've made this library automatically refresh oauth details whenever they've expired mid-call. That means after any call the oauth token may have changed, which you will need to check for (and save the new token). I figure it's probably easier to check for changed tokens than catching token expiration exceptions and handling those. Soz brah.

You have two options: checking after every call, or subscribing to events.

Logging

If you want to follow automated events for debugging, grab MonoLog (or other) and pass an instance as 'logger' during initialization.

Authorization

Authorization obtains OAuth2 keys for the Fitbit account in question. You must have a valid client id, client secret, and redirect uri from the Fitbit developer website to use this library. You must specify all of the scopes you wish to use here; you will need to re-authorize the user if you want to expand your scopes later.

Automated Authorization Flow

If you're lazy (hi!) you can have the library redirect the user to the Fitbit website for you.

Manual Authorization Flow

If you're lazy (hi!) you can have the library redirect the user to the Fitbit website for you.

Authorization involves sending the user to Fitbit's website with a 'state' code so we can verify the request came from us. Store the state and send the user off to the uri.

When the user returns to the redirect_uri specified on the Fitbit developer website, there will be a query ($_GET) parameter set with the state we stored above; check they match to ensure the request originated with us.

Restoring access

Making a request

Inspect the FitbitPHPOAuth2 class to find the appropriate method. In this case, I want all activities on a date:

License

The MIT License (MIT).


All versions of fitbit-php-oauth2 with dependencies

PHP Build Version
Package Version
Requires league/oauth2-client Version ~1.2
psr/log Version ^1.0
sabre/event Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package brulath/fitbit-php-oauth2 contains the following files

Loading the files please wait ....