<?php // Docs from https://github.com/djchen/oauth1-php // Load Composer include 'vendor/autoload.php'; $oauth = new \djchen\OAuth1(array('consumerKey' => 'bc260b6a699b0d9d01e9a4625022c481', 'consumerSecret' => '31a9400594f48bb0655b230dafcf141e', 'token' => '9dcbca74321756c0d1a1bd890d20b485', 'tokenSecret' => 'b2dd392ad93eda02fff839c671862f72', 'requestTokenUrl' => 'https://api.fitbit.com/oauth/request_token', 'accessTokenUrl' => 'https://api.fitbit.com/oauth/access_token')); // GET call $response = $oauth->get("https://api.fitbit.com/1/user/-/profile.json"); echo '<div class="small-6 medium-3 large-2 large-offset-2 columns">'; echo '<div class="badgebox">'; echo '<img src="' . $response->body->user->topBadges[0]->image50px . '">'; echo '<p><strong>' . $response->body->user->topBadges[0]->description . '</strong></p>'; echo '<p class="shortname"><strong>' . $response->body->user->topBadges[0]->shortName . '</strong></p>'; $date = new DateTime($response->body->user->topBadges[0]->dateTime); echo '<p>' . $date->format('D jS \\of M') . '</p>'; echo '</div>'; echo '</div>'; echo '<div class="small-6 medium-3 large-2 columns">'; echo '<div class="badgebox">'; echo '<img src="' . $response->body->user->topBadges[1]->image50px . '">'; echo '<p><strong>' . $response->body->user->topBadges[1]->description . '</strong></p>'; echo '<p class="shortname"><strong>' . $response->body->user->topBadges[1]->shortName . '</strong></p>'; $date = new DateTime($response->body->user->topBadges[1]->dateTime); echo '<p>' . $date->format('D jS \\of M') . '</p>'; echo '</div>'; echo '</div>'; echo '<div class="small-6 medium-3 large-2 columns">'; echo '<div class="badgebox">'; echo '<img src="' . $response->body->user->topBadges[2]->image50px . '">'; echo '<p><strong>' . $response->body->user->topBadges[2]->description . '</strong></p>'; echo '<p class="shortname"><strong>' . $response->body->user->topBadges[2]->shortName . '</strong></p>';
<?php // Docs from https://github.com/djchen/oauth1-php // Load Composer include 'vendor/autoload.php'; $oauth = new \djchen\OAuth1(array('consumerKey' => 'bc260b6a699b0d9d01e9a4625022c481', 'consumerSecret' => '31a9400594f48bb0655b230dafcf141e', 'token' => '9dcbca74321756c0d1a1bd890d20b485', 'tokenSecret' => 'b2dd392ad93eda02fff839c671862f72', 'requestTokenUrl' => 'https://api.fitbit.com/oauth/request_token', 'accessTokenUrl' => 'https://api.fitbit.com/oauth/access_token')); // GET call $response = $oauth->get("https://api.fitbit.com/1/user/-/profile.json"); // GET call $response = $oauth->get("https://api.fitbit.com/1/user/-/activities/date/" . date('Y-m-d') . ".json"); $count_total = 10000; if ($response->body->summary->steps < $count_total) { echo '<p><span class="count warning">' . $response->body->summary->steps . '</span> steps today </p>'; } else { if ($response->body->summary->steps > $count_total) { echo '<p><span>' . $response->body->summary->steps . '</span> steps today </p>'; } } echo '<p><span>' . $response->body->summary->floors . '</span> floor climbed </p>'; echo '<p><span>' . round($response->body->summary->distances[0]->distance * 0.62137, 2) . '</span> miles walked </p>';