Get your data from Nike+
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 hosted by Google Code and has been downloaded around 2936 times.
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.5.php';
$n = new NikePlusPHP('email@address.com', '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.5.php';
$n = new NikePlusPHP('email@address.com', 'password');
$activites = $n->activities();
echo count($activities);
?>
From verson 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.5.php';
$n = new NikePlusPHP('email@address.com', '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.5.php';
$n = new NikePlusPHP('email@address.com', '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.5.php';
$n = new NikePlusPHP('email@address.com', '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.5.php';
$n = new NikePlusPHP('email@address.com', 'password');
$activities = $n->allTime();
echo $n->toMiles($activities->lifetimeTotals->distance);
?>
The calories you have burned using Nike+.
<?php
require_once 'nikeplusphp.4.5.php';
$n = new NikePlusPHP('email@address.com', 'password');
$activities = $n->allTime();
echo $activities->lifetimeTotals->calorie;
?>
The duration of your last activity.
<?php
require_once 'nikeplusphp.4.5.php';
$n = new NikePlusPHP('email@address.com', '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.5.php';
$n = new NikePlusPHP('email@address.com', '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.5.php';
$n = new NikePlusPHP('email@address.com', '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.5.php';
$n = new NikePlusPHP('email@address.com', 'password');
$activity = $n->mostRecentActivity();
echo $n->calculatePace($activity->activity->duration, $n->toMiles($activity->activity->distance));
?>
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 hello@charanj.it
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: