Get your data from Nike+
The website will remain here for historical purposes, but sadly the class no longer functions as intended.
Nike changed from using XML to JSON and changed the way in which the data is returned, so Nike+
While I would love to rewrite it, I do not have the time right now to do this. Logging in still works, so if you're interested enough, you may be able to figure out which JSON feeds do what and still get the information you require from Nike in the absence of an official API.
Nike+PHP is PHP class that gets you your data from the Nike+ website, including activities, all time statistics and some aspects of NikeFuel. All you need to get started is PHP 5 with cURL and JSON.
Follow Nike+PHP on twitter and Google+.
To make Nike+PHP more consistent with Nike+ there have been small changes to the code. From version 4.4+ private methods and variables now begin with an underscore and instead of run and runs, items are now referred to as either an activity or activities.
Please check the documentation and examples for more information.
Nike+PHP is now hosted on this domain. Download the file using the link above and remove the .txt extension.
There are a number of things you can do with Nike+PHP, the first thing you need to do is login:
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
?>
Once you've successfully logged in, you can call any of the following public methods.
To help you get started, here are some examples of how to use Nike+PHP.
Count how many activities you have recorded with Nike+
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activities = $n->activities();
echo count($activities);
?>
From version 4.2, the method returns an array of objects, rather than an object returning an array of objects.
Get the information about a specific activity.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activity = $n->activity($activityId);
var_dump($activity);
?>
From version 4.4, the method returns just the data, rather than an array of one item that then contains the data.
Get the GPS data for an activity, if available.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activity = $n->activity($activityId);
var_dump($activity->activity->geo);
?>
The distance you have covered using Nike+, always returned in Km.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activities = $n->allTime();
echo $activities->lifetimeTotals->distance;
?>
The distance you have covered using Nike+, always returned in Km, but converted into miles (2d.p.).
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activities = $n->allTime();
echo $n->toMiles($activities->lifetimeTotals->distance);
?>
The calories you have burned using Nike+.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activities = $n->allTime();
echo $activities->lifetimeTotals->calorie;
?>
The duration of your last activity.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activity = $n->mostRecentActivity();
echo $n->formatDuration($activity->activity->metrics->duration);
?>
There are a few ways to calculate your pace, depending on what units you want use. This first example shows how to get the pace in km.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activity = $n->mostRecentActivity();
echo $n->calculatePace($activity->activity->duration, $activity->activity->distance);
?>
There are two ways to calculate the pace of a activity in miles, depending on what you pass through. This first example works by setting $toMiles to true.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activity = $n->mostRecentActivity();
echo $n->calculatePace($activity->activity->duration, $activity->activity->distance, true);
?>
This second example works by setting the $distance to reflect the distance of the activity in miles.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$activity = $n->mostRecentActivity();
echo $n->calculatePace($activity->activity->duration, $n->toMiles($activity->activity->distance));
?>
Simply pass the date for the Fuel you want to retrieve.
<?php
require_once 'nikeplusphp.4.6.0.php';
$n = new NikePlusPHP('[email protected]', 'password');
$fuel = $n->fuelActivity('2015/01/01'); // 1st Jan 2015
echo $fuel->activityDetail->activity->fuelAmt;
Below you will find examples of sites or products that use the Nike+PHP code.
If you need help using Nike+PHP or if you would like to contribute to the project, please feel free to send feature requests or contributions to [email protected]
Here are those that have already contributed to or inspired the project:
As well as looking for suggestions for features, which you can submit to the email address above, I have now included a list of things I have to do on the project and features I would ultimately like to introduce.
Nike sell a range of products to compliment the Nike+ service, including running shoes, GPS watches and wristbands.
You can purchase Nike+ compatible iPods from Apple, Nike+ music from iTunes and mobile apps from the App Store and Google Play.
You can also buy relevant products from the stores below: