2017 © Pedro Peláez
 

library php-runtastic

It is a class to gain easy access to Runtastic (www.runtastic.com) activity data via PHP. This is a very dirty approach since Runtastic doesn't offer an official API.

image

sm0nster/php-runtastic

It is a class to gain easy access to Runtastic (www.runtastic.com) activity data via PHP. This is a very dirty approach since Runtastic doesn't offer an official API.

  • Monday, November 7, 2016
  • by MateuszBlaszczyk
  • Repository
  • 2 Watchers
  • 0 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 22 Forks
  • 0 Open issues
  • 3 Versions
  • 15 % Grown

The README.md

Runtastic PHP Library

Runtastic-PHP is a PHP library that allows you to connect to Runtastic (www.runtastic.com) and get all your activities. This is a very dirty approach since Runtastic doesn't offer an official API., (*1)

The only, (*2)

Getting Started

Prerequisites

  • PHP >= 5.2
  • JSON and CURL (with SSL) PHP extensions.

Installation

composer require timoschlueter/php-runtastic

Basic Usage

<?php

require __DIR__ . '/path/to/autoload.php';

use Runtastic\Runtastic;

$r = new Runtastic();
$r->setUsername("your@email.com")->setPassword("your@password");

$activities = $r->getActivities();
echo "Total Number of activities: " . count($activities) . PHP_EOL;

foreach ($activities as $activity) {
    echo $activity->id . PHP_EOL;
}

Runtastic Class Methods

setUsername()

[Mandatory] Sets the username used for logging into Runtastic, (*3)

setPassword()

[Mandatory] Sets the password used for logging into Runtastic, (*4)

setTimeout()

Sets the connection timeout (in seconds) for cURL. Defaults to 10, (*5)

login()

Logs into Runtastic (requires valid username and password), (*6)

logout()

Logs out and closes the cURL connection, (*7)

getUsername()

Returns the Username used by Runtastic, (*8)

getUid()

Returns the UID used by Runtastic, (*9)

getToken()

Returns the session's token, (*10)

getActivities($iWeek = null, $iMonth = null, $iYear = null)

Returns every activity in your Runtastic account as a RuntasticActivityList (usable as array) of objects. If - $iWeek is set, all activities within requested number of week will be returned (week starts on monday). - $iMonth is set, all activities within requested month will be returned. - $iYear is set, all activities within the requested year will be returned., (*11)

$iWeek and $iMonth can be used together with $iYear. if $iYear is null, the current year will be used for filtering. If you don't specify any argument, then, this function will return all activities., (*12)

RuntasticActivityList Class Methods

The function getActivities of the Runtastic class that we saw before returns an RuntasticActivityList object. This class allows you to filter easily the activities using the following method:, (*13)

filterBy([])

You can filter by every object defined in the Activity Object. This is what a typical activity object looks like:, (*14)

    array(1) {
        [0]=>
            object(stdClass)#11 (24) {
            ["id"]=>
            int(1111111)
            ["type"]=>
            string(7) "cycling"
            ["type_id"]=>
            int(3)
            ["duration"]=>
            int(630003)
            ["distance"]=>
            int(2435)
            ["pace"]=>
            float(4.31213333333)
            ["speed"]=>
            string(6) "13.914"
            ["kcal"]=>
            int(48)
            ["heartrate_avg"]=>
            int(0)
            ["heartrate_max"]=>
            int(0)
            ["elevation_gain"]=>
            float(18)
            ["elevation_loss"]=>
            float(19)
            ["surface"]=>
            string(4) "road"
            ["weather"]=>
            string(5) "sunny"
            ["feeling"]=>
            string(7) "awesome"
            ["weather_id"]=>
            int(1)
            ["feeling_id"]=>
            int(1)
            ["surface_id"]=>
            int(1)
            ["notes"]=>
            string(0) ""
            ["page_url"]=>
            string(47) "/en/users/Example-User/sport-sessions/1111111"
            ["create_route_url_class"]=>
            string(0) ""
            ["create_route_url"]=>
            string(36) "/en/routes/new?sport_session=1111111"
            ["map_url"]=>
            string(201) ""
            ["date"]=>
            object(stdClass)#8 (6) {
                ["year"]=>
                int(2011)
                ["month"]=>
                string(2) "05"
                ["day"]=>
                string(2) "19"
                ["hour"]=>
                int(22)
                ["minutes"]=>
                int(18)
                ["seconds"]=>
                int(23)
            }
        }
    }

So, for example, you can filter by like this:, (*15)

$activities = $r->getActivities()->filterBy(["type"=>"strolling", "weather"=>"good"]);
echo "Number of strolling activities with good weather: " . count($activities) . PHP_EOL;

LICENSE

The MIT License (MIT), (*16)

Copyright (c) 2014 Timo Schlueter timo.schlueter@me.com, (*17)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*18)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*19)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*20)

The Versions

07/11 2016

dev-master

9999999-dev

It is a class to gain easy access to Runtastic (www.runtastic.com) activity data via PHP. This is a very dirty approach since Runtastic doesn't offer an official API.

  Sources   Download

MIT

The Requires

  • php >=5.2.0
  • ext-curl *

 

by Manuel Garcia
by Marcin Szymanski
by Timo Schlueter

api php sports runtastic workouts

05/10 2016

1.0.x-dev

1.0.9999999.9999999-dev

It is a class to gain easy access to Runtastic (www.runtastic.com) activity data via PHP. This is a very dirty approach since Runtastic doesn't offer an official API.

  Sources   Download

MIT

The Requires

  • php >=5.2.0
  • ext-curl *

 

by Manuel Garcia
by Marcin Szymanski
by Timo Schlueter

api php sports runtastic workouts

18/11 2015

dev-pagination

dev-pagination

It is a class to gain easy access to Runtastic (www.runtastic.com) activity data via PHP. This is a very dirty approach since Runtastic doesn't offer an official API.

  Sources   Download

MIT

The Requires

  • php >=5.2.0
  • ext-curl *

 

by Timo Schlueter