承接 jyokum/healthgraph 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jyokum/healthgraph

Composer 安装命令:

composer require jyokum/healthgraph

包简介

PHP wrapper for the RunKeeper Health Graph API built on Guzzle

README 文档

README

Latest Stable Version Total Downloads Build Status

Health Graph Client

The Health Graph Client is a PHP wrapper for the Health Graph API

Installation via Composer

Add HealthGraph in your composer.json:

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

Download the library:

$ php composer.phar update

After installing, you need to require Composer's autoloader somewhere in your code:

require_once 'vendor/autoload.php';

Generating a Connect link/button

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();

统计信息

  • 总下载量: 294
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2013-12-30