2017 © Pedro Peláez
 

library strava

A simple-to-use (single file!) library to easily interrogate the Strava v3 API

image

dawguk/strava

A simple-to-use (single file!) library to easily interrogate the Strava v3 API

  • Wednesday, November 11, 2015
  • by dawguk
  • Repository
  • 1 Watchers
  • 4 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Strava v3 API Client

This is a single-file-library that you can use to interrogate the Strava v3 API. It handles authentication as well as whatever API calls you want to make (as long as they are valid), (*1)

Usage

First off you need to construct a configuration array. The array should contain at least the following information:, (*2)

  • CLIENT_ID
  • CLIENT_SECRET
  • REDIRECT_URI
  • ACCESS SCOPE

CLIENT_ID and CLIENT_SECRET should be taken from the My API Application section of the site. Valid ACCESS_SCOPE values can be found in the Strava API documentation, (*3)

Optionally, you can supply the following addition configuration options:, (*4)

  • CACHE_DIRECTORY
  • ACCESS_TOKEN

If CACHE_DIRECTORY isn't supplied, the library falls back to writing to /tmp, (*5)

If ACCESS_TOKEN is supplied, we bypass authorization and token exchange - assuming the ACCESS_TOKEN is correct., (*6)

Examples

To configure the client, you would define your parameters as follows:, (*7)

<?php
$arrConfig = array(
   'CLIENT_ID' => 1354,
   'CLIENT_SECRET' => 'here is my client secret',
   'REDIRECT_URI' => 'http://localhost/example.php',
   'CACHE_DIRECTORY' => '/path/to/cache/dir/',
   'ACCESS_SCOPE' => 'write'
);

The following example GETs information about the authenticated athlete:, (*8)

<?php
$objStrava = new \dawguk\Strava($arrConfig);
print_r($objStrava->get('athlete', array()));

The following example PUTs (updates) the weight information for the current athlete:, (*9)

<?php
$objStrava = new \dawguk\Strava($arrConfig);
print_r($objStrava->put('athlete', array('weight' => 62.8)));

Notes

Currently the library will only store a single access token, so isn't ready for multi-user authentication. This is expected to change in the future, with token storage abstracted out., (*10)

Now available on packagist.org ;D, (*11)

References

http://strava.github.io/api/v3 is a good place to start., (*12)

The Versions

11/11 2015

dev-master

9999999-dev

A simple-to-use (single file!) library to easily interrogate the Strava v3 API

  Sources   Download

MIT

The Requires

  • php >=5.3.0