<?php $response = new stdClass(); $activity_id = $_GET['id']; if (empty($activity_id)) { $response->error = true; $response->message = "No activity specified."; echo json_encode($response); die; } // 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 (!$stracof->is_loaded()) { $response->error = true; $response->message = "There was an error accessing Strava. Please login again."; echo json_encode($response); die; } echo json_encode($stracof->get_activity($activity_id));
<html lang="en"> <head> <meta charset="utf-8"> <title>StraCof | Riding for coffee points</title> <link rel="stylesheet" href="css/stracof.css"> </head> <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;