PHP code example of sylus-code / multisport-mysports-wrapper

1. Go to this page and download the library: Download sylus-code/multisport-mysports-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sylus-code / multisport-mysports-wrapper example snippets


use GuzzleHttp\Client;
use SylusCode\MultiSport\MysportsWrapper\Api\ApiWrapper;
use SylusCode\MultiSport\MysportsWrapper\Api\CookieAuthenticator;
use SylusCode\MultiSport\MysportsWrapper\Workout\WorkoutParser;
use SylusCode\MultiSport\MysportsWrapper\Workout\WorkoutTypeResolver;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

        $client = new Client();
        $workoutParser = new WorkoutParser();
        
        // you can overwrite type resolver if you need more logic there
        $workoutTypeResolver = new WorkoutTypeResolver();
        $auth = new CookieAuthenticator($client, '******@gmail.com', 'VeryStrongPassw0rd');
        
        $api = new ApiWrapper($client, $auth, $workoutParser, $workoutTypeResolver);
        $result = $api->getWorkouts($options);
        
        var_dump($result);
        
        // Example output:
        array(1) {
          [0]=>
          object(SylusCode\MultiSport\Workout\Workout)#1503 (14) {
            ["time":"SylusCode\MultiSport\Workout\Workout":private]=>
            NULL
            ["type":"SylusCode\MultiSport\Workout\Workout":private]=>
            object(SylusCode\MultiSport\Workout\Type)#1457 (2) {
              ["id":"SylusCode\MultiSport\Workout\Type":private]=>
              int(1)
              ["name":"SylusCode\MultiSport\Workout\Type":private]=>
              string(8) "Bieganie"
            }
            ["distance":"SylusCode\MultiSport\Workout\Workout":private]=>
            float(595.98)
            ["calories":"SylusCode\MultiSport\Workout\Workout":private]=>
            int(36)
            ["durationTotal":"SylusCode\MultiSport\Workout\Workout":private]=>
            int(420)
            ["points":"SylusCode\MultiSport\Workout\Workout":private]=>
            array(18) {
              [0]=>
              object(SylusCode\MultiSport\Workout\Point)#1501 (7) {
                ["time":"SylusCode\MultiSport\Workout\Point":private]=>
                object(DateTime)#1510 (3) {
                  ["date"]=>
                  string(26) "2020-11-12 07:28:17.000000"
                  ["timezone_type"]=>
                  int(2)
                  ["timezone"]=>
                  string(1) "Z"
                }
                ["latitude":"SylusCode\MultiSport\Workout\Point":private]=>
                float(51.392342)
                ["longtitude":"SylusCode\MultiSport\Workout\Point":private]=>
                float(16.696368)
                ["altitude":"SylusCode\MultiSport\Workout\Point":private]=>
                float(113.8)
                ["distance":"SylusCode\MultiSport\Workout\Point":private]=>
                float(0)
                ["heartRate":"SylusCode\MultiSport\Workout\Point":private]=>
                int(108)
                ["speed":"SylusCode\MultiSport\Workout\Point":private]=>
                float(0)
              }
              ..