Exemplo n.º 1
0
 /**
  * @covers HealthGraph\HealthGraphClient::factory
  */
 public function testFactoryInitializesClient()
 {
     $client = HealthGraphClient::factory();
     $this->assertEquals('https://api.runkeeper.com', $client->getBaseUrl());
 }
Exemplo n.º 2
0
 * @var string
 */
$client_id = 'YOUR_CLIENT_ID';
$client_secret = 'YOUR_CLIENT_SECRET';
$redirect_url = 'http://localhost/runkeeper_mass_import';
/**
 * [$button Runkeeper connect button]
 * @var [type]
 */
$button = Authorization::getAuthorizationButton($client_id, $redirect_url);
// Spit connect button to the page
echo $button['html'];
// the healthgraph api returns ?code=xxxx on success...I havent confirmed this but it should be on success
if (isset($_REQUEST['code'])) {
    $token = Authorization::authorize($_GET['code'], $client_id, $client_secret, $redirect_url);
    $hgc = HealthGraphClient::factory();
    $hgc->getUser(array('access_token' => $token['access_token'], 'token_type' => $token['token_type']));
    // Scan all files in the data folder excluding .DS_Store
    // TODO: Check if valid GPX file. There is no error handling for that yet
    $dir = getcwd() . '/data/';
    $files = scandir($dir);
    $files = array_diff($files, array('.', '..', '.DS_Store'));
    $gpxCount = 0;
    $gpxData = array();
    foreach ($files as $file) {
        $xml = simplexml_load_file($dir . $file);
        $track = array();
        $count = 0;
        // Dump track data to an array
        foreach ($xml->trk->trkseg->trkpt as $trackInfo) {
            $track[$count] = array("latitude" => floatval($trackInfo->attributes()->lat), "longitude" => floatval($trackInfo->attributes()->lon), "altitude" => floatval($trackInfo->ele), "timestamp" => strtotime((string) $trackInfo->time), "type" => $count === 0 ? "start" : "gps");