debug = true; $client->debug_http = true; $client->server = 'Fitbit2'; $client->redirect_uri = 'http://'.$_SERVER['HTTP_HOST']. dirname(strtok($_SERVER['REQUEST_URI'],'?')).'/index.php'; //Fitbit Callback URL is http://compsci02.snc.edu/cs460/2017/wolftd/oauth2/index.php $client->client_id = '228C63'; $application_line = __LINE__; $client->client_secret = 'f9cc574b526d9180c08bbb447494de9a'; if(strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) die('Please go to Fitbit application registration page https://dev.fitbit.com/apps/new , '. 'create an application, and in the line '.$application_line. ' set the client_id to Consumer key and client_secret with Consumer secret. '. 'The Callback URL must be '.$client->redirect_uri).' Make sure this URL is '. 'not in a private network and accessible to the Fitbit site.'; /* API permissions */ $client->scope = 'activity sleep heartrate';//add heartrate later if(($success = $client->Initialize())) { if(($success = $client->Process())) { if(strlen($client->access_token)) { //$success = $client->CallAPI( //'https://api.fitbit.com/1/user/-/profile.json', //'GET', array(), array('FailOnAccessError'=>true), $user); $success = $client->CallAPI( 'https://api.fitbit.com/1/user/-/activities/date/'.date('Y-m-d').'.json', 'GET', array(), array('FailOnAccessError'=>true), $activities); $success = $client->CallAPI( 'https://api.fitbit.com/1/user/-/sleep/date/'.date('Y-m-d').'.json', 'GET', array(), array('FailOnAccessError'=>true), $sleep); $success = $client->CallAPI( 'https://api.fitbit.com/1/user/-/activities/heart/date/today/1d/1min/time/'.date('H:i',strtotime('-20 minutes')).'/'.date('H:i',strtotime('now')).'.json', //https://api.fitbit.com/1/user/-/activities/heart/date/today/1d/1sec/time/00:00/00:01.json' <-- intra data 'GET', array(), array('FailOnAccessError'=>true), $heartrate); //This is collecting heart data for the last 20 minutes you can adjust to anytime you want all the way to the time you started wearing your fit bit } } $success = $client->Finalize($success); } if($client->exit) exit; if($success) { //$client->Output(); ?> Fitbit OAuth client results ', 'You have logged in successfully with Fitbit!'; ?> OAuth client error

OAuth client error

Error: error); ?>