PHP code example of namelivia / fitbit-http-php

1. Go to this page and download the library: Download namelivia/fitbit-http-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

namelivia / fitbit-http-php example snippets


$api = new \Namelivia\Fitbit\Api\Api(
	'someClientId', #clientId
	'someClientSecret', #clientSecret
	'https://myapp.com/authorized', #redirectUrl
	'/tmp/token' #tokenPath
);

if (!$api->isAuthorized()) {
	echo 'Go to: ' . $api->getAuthUri() . "\n";
	echo "Enter verification code: \n";
	$code = trim(fgets(STDIN, 1024));
	$api->setAuthorizationCode($code);
}

if (!$api->isInitialized()) {
	$api->initialize();
}

$fitbit = new \Namelivia\Fitbit\Api\Fitbit($api);

$fitbit->activities()->favorites()->get();
bash
$ composer