//the passed categories are parsed into an array
         case 'categories':
             $categories = [];
             foreach ($data->xpath('value/array/data/value/string') as $cat) {
                 array_push($categories, (string) $cat);
             }
             $obj->categories = $categories;
             break;
             //this is used for title/description
         //this is used for title/description
         default:
             $obj->{$data->name} = (string) $data->value->string;
     }
 }
 //authenticate fitbit connection
 $fitbit = new FitBitPHP($conskey, $conssec);
 $fitbit->setOAuthDetails($user['FitBitToken'], $user['FitBitSecret']);
 __log("{$xml->params}->param[3]->value->struct->member[0]->value->string: " . $xml->params->param[3]->value->struct->member[0]->value->string);
 $body = $xml->params->param[3]->value->struct->member[1]->value->string;
 switch ($xml->params->param[3]->value->struct->member[0]->value->string) {
     case 'logBody':
         list($date, $weight, $fat, $bicep, $calf, $chest, $forearm, $hips, $neck, $thigh, $waist) = explode(",", $body);
         $date = dateconverter($date);
         $xml = $fitbit->logWeight($weight, $date);
         success('<string>' . $response->status_code . '</string>');
         break;
     case 'logActivity':
         list($date, $activityId, $duration, $calories, $distance, $distanceUnit, $activityName) = explode(",", $body);
         $date = dateconverter($date);
         $xml = $fitbit->logActivity($date, $activityId, $duration, $calories, $distance, $distanceUnit, $activityName);
         success('<string>' . $response->status_code . '</string>');
<?php

$body = $_GET['body'];
list($weight, $date) = explode(",", $body);
require_once dirname(__FILE__) . '/load.php';
require 'fitbitphp.php';
$fitbit = new FitBitPHP($conskey, $conssec);
$fitbit->setOAuthDetails('d3f4df585445526bf1ade9c8242bb8fd', '2c9313b5bff62c76a549fe3cd5e458b3');
//WONT WORK NEED TO FILL IN
$xml = $fitbit->logWeight($weight, $date);
print_r($xml);
</div>

<div class="wrap">
    <form method="post"> 
        <h2><?php 
_e('Add Friend Profile', 'hwd');
?>
</h2>
        <?php 
_e('Easily create new profile with API and Fitbit ID', 'hwd');
?>
        

    <?php 
if (isset($_POST['encodedId']) && '' != $_POST['encodedId']) {
    $fitbit_php = new FitBitPHP(HWD_CONSUMER_KEY, HWD_CONSUMER_SECRET, 0, null, 'json');
    $fitbit_php->setOAuthDetails(HWD_FITBIT_TOKEN, HWD_FITBIT_SECRET);
    $fitbit_php->setUser($_POST['encodedId']);
    $profile = $fitbit_php->getProfile();
    // Create post object
    $my_post = array('post_title' => $profile->user->encodedId, 'post_content' => $profile->user->encodedId, 'post_author' => 1, 'post_status' => 'publish', 'post_type' => 'friend');
    // Insert the post into the database
    $post_id = wp_insert_post($my_post, true);
    if (!is_wp_error($post_id)) {
        foreach ($profile->user as $meta_key => $meta_value) {
            add_post_meta($post_id, $meta_key, $meta_value, true);
        }
        ?>
          <div id="message" class="updated">
              <p><strong><?php 
        _e('Friend Added.', 'hwd');
Exemple #4
0
<?php

require_once 'bootstrap.php';
require_once 'fitbitphp.php';
$fitbit = new FitBitPHP(FITBIT_KEY, FITBIT_SECRET);
$fitbit->setMetric(0);
$status = 0;
if (isset($_GET['status'])) {
    $status = intval($_GET[status]);
} else {
    if ($fitbit->sessionStatus() == 2) {
        $status = 2;
    } else {
        if ($fitbit->sessionStatus() == 1) {
            $status = 3;
        }
    }
}
?>
<!--
// *****************************************************************************
// *
// *
// *          THIS IS THE SOURCE CODE, PLEASE DON'T HACK THIS SITE :)
// *
// *
// *****************************************************************************
-->
<!DOCTYPE html>
<html>
<head>