2017 © Pedro Peláez
 

library healthgraph

PHP wrapper for the RunKeeper Health Graph API built on Guzzle

image

jyokum/healthgraph

PHP wrapper for the RunKeeper Health Graph API built on Guzzle

  • Saturday, January 4, 2014
  • by jyokum
  • Repository
  • 1 Watchers
  • 5 Stars
  • 128 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Latest Stable Version Total Downloads Build Status, (*1)

Health Graph Client

The Health Graph Client is a PHP wrapper for the Health Graph API, (*2)

Installation via Composer

Add HealthGraph in your composer.json:, (*3)

{
    "require": {
        "jyokum/healthgraph": "*"
    }
}

Download the library:, (*4)

``` bash $ php composer.phar update, (*5)


After installing, you need to require Composer's autoloader somewhere in your code: ```php require_once 'vendor/autoload.php';
require_once 'vendor/autoload.php';
use HealthGraph\Authorization;

$client_id = 'xxxxxxxxxxxxxxxxxxxxx';
$redirect_url = 'http://example.com/authorize';

// Link
$link = Authorization::getAuthorizationLink($client_id, $redirect_url);
echo "<a href='$link'>Connect</a>";

// Button
$button = Authorization::getAuthorizationButton($client_id, $redirect_url);
echo $button['html'];

Obtain a token from an auth code

require_once 'vendor/autoload.php';
use HealthGraph\Authorization;

$client_id = 'xxxxxxxxxxxxxxxxxxxxx';
$client_secret = 'xxxxxxxxxxxxxxxxxxxxx';
$redirect_url = 'http://example.com/authorize';

if (isset($_REQUEST['code'])) {
    $token = Authorization::authorize($_GET['code'], $client_id, $client_secret, $redirect_url);
    some_function_to_save_the_token($token);
}

Revoke a token

require_once 'vendor/autoload.php';
use HealthGraph\Authorization;

$token = some_function_to_retrieve_the_token();
Authorization::deauthorize($token->access_token);

Retrieve data for a user

require_once 'vendor/autoload.php';
use HealthGraph\HealthGraphClient;

$token = some_function_to_retrieve_the_token();

$hgc = HealthGraphClient::factory();
$hgc->getUser(array(
    'access_token' => $token['access_token'],
    'token_type' => $token['token_type'],
));

// get profile
$hgc->GetProfile();

// get settings
$hgc->GetSettings();

// get fitness activity list
$activities = $hgc->FitnessActivityFeed()->getAll();

Update profile

$hgc = HealthGraphClient::factory();
$hgc->getUser(array(
    'access_token' => $token['access_token'],
    'token_type' => $token['token_type'],
));
$data = array('athlete_type' => 'Athlete');
$hgc->UpdateProfile($data);

Get fitness activities

$hgc = HealthGraphClient::factory();
$hgc->getUser(array(
    'access_token' => $token['access_token'],
    'token_type' => $token['token_type'],
));

// Get the entire feed, this could return a lot of data.
$command = $hgc->getIterator('GetFitnessActivityFeed');
$result = $command->toArray();

// Get the 5 most recent activities.
$command = $hgc->getIterator('GetFitnessActivityFeed')->setLimit(5);
$result = $command->toArray();

Add a new fitness activity

$hgc = HealthGraphClient::factory();
$hgc->getUser(array(
    'access_token' => $token['access_token'],
    'token_type' => $token['token_type'],
));
$command = $hgc->getCommand('NewFitnessActivity', array(
    "type" => "Running",
    "start_time" => "Sat, 1 Jan 2011 00:00:00",
    "duration" => 600,
    "total_distance" => 1000,
    "notes" => "Ran 1000 meters in 600 seconds"
));
$result = $command->execute();

The Versions

04/01 2014

dev-master

9999999-dev https://github.com/jyokum/healthgraph

PHP wrapper for the RunKeeper Health Graph API built on Guzzle

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jeff Yokum

guzzle runkeeper health graph

04/01 2014

0.3.0

0.3.0.0 https://github.com/jyokum/healthgraph

PHP wrapper for the RunKeeper Health Graph API built on Guzzle

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jeff Yokum

guzzle runkeeper health graph

30/12 2013

0.2.0

0.2.0.0 https://github.com/jyokum/healthgraph

PHP wrapper for the RunKeeper Health Graph API built on Guzzle

  Sources   Download

The Requires

 

The Development Requires

by Jeff Yokum

guzzle runkeeper health graph

01/12 2013

0.1.0

0.1.0.0

Health Graph API

  Sources   Download

The Requires

  • php >=5.3.0
  • lib-curl *