コード例 #1
0
ファイル: index.php プロジェクト: jgallant/drustracof
<body>

<?php 
// I'm going to store the access token for the user in a session variable.
session_start();
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/StraCof.php';
$stracof = new StraCof($stracof_config);
// If we don't have a code or a token we'll start again.
// In a real app, we'd be setting a cookie and also logging some DB stuff.
if (!$stracof->is_loaded()) {
    echo "<a href='https://www.strava.com/oauth/authorize?client_id=7622&response_type=code&redirect_uri=http://jgallant.ca/stracof'>Login with Strava</a>";
    die;
}
echo "<h2>Hello, {$stracof->get_user_info()->firstname}!</h2>";
$activities = $stracof->get_user_activities();
if (empty($activities)) {
    echo "You don't have any activities! Go ride a bike and come back.";
    die;
}
$activity_options = "<option value='' selected disabled>Select an activity</option>" . PHP_EOL;
foreach ($activities as $activity) {
    $activity_options .= "<option value='{$activity->id}'>{$activity->name}</option>" . PHP_EOL;
}
echo "<select id='activities'>{$activity_options}</select>";
?>

<div id="map"></div>
<div class="total_container"></div>
<div class="points_container"></div>