Download the PHP package iamstuartwilson/strava without Composer
On this page you can find all versions of the php package iamstuartwilson/strava. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iamstuartwilson/strava
More information about iamstuartwilson/strava
Files in iamstuartwilson/strava
Package strava
Short Description PHP implementation of the Strava V3 API
License MIT
Informations about the package strava
StravaApi
The class simply houses methods to help send data to and receive data from the API. Please read the API documentation to see what endpoints are available.
There is no file upload support at this time.
Installation
With Composer
Or add it manually to your composer.json
:
Manually
Copy StravaApi.php
to your project and require it in your application as described in the next section.
Getting Started
Instantiate the class with your client_id and client_secret from your registered app:
If you're just testing endpoints/methods you can skip the authentication flow and just use the access token from your settings page.
You will then need to authenticate your strava account by requesting an access code. You can generate a URL for authentication using the following method:
When a code is returned you must then exchange it for an access token and a refresh token for the authenticated user:
The token exchange result contains among other data the tokens. You can access them as attributes of the result object:
Before making any requests you must set the access and refresh tokens as returned from your token exchange result or via your own private token from Strava:
Example oAuth2 Authentication Flow
examples/oauth-flow.php
demonstrates how the oAuth2 authentication flow works.
- Choose how to load the
StravaApi.php
– either via Composer autoloader or by manually requiring it. - Replace the three config values
CALLBACK_URL
,STRAVA_API_ID
, andSTRAVA_API_SECRET
at the top of the file - Place the file on your server so that it's accessible at
CALLBACK_URL
- Point your browser to
CALLBACK_URL
and start the authentication flow.
The scripts prints a lot of verbose information so you get an idea on how the Strava oAuth flow works.
Example Requests
Once successfully authenticated you're able to communicate with Strava's API.
All actions that change Strava contents (post
, put
, delete
) will need the scope set to write in the authentication flow.
Get Athlete Stats
List Athlete Activities
Some API endpoints support GET parameters:
Post a new activity
Update a athlete's weight
Releases
See CHANGELOG.md.