Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: 10REM/php-garmin-connect
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.4
Choose a base ref
...
head repository: 10REM/php-garmin-connect
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: php
sudo: false

php:
- 5.5
- 5.6
- 7.0
- 7.2
- 7.3
- 7.4
- nightly

matrix:
include:
- php: hhvm
dist: trusty
allow_failures:
- php: nightly
fast_finish: true

install:
- composer self-update
- composer install --no-interaction

script:
- ./vendor/bin/phpcs --standard=phpcs.xml -s src
98 changes: 98 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [v1.7.0] - 2021-05-19

### Changed

- Documentation updated thanks to @AnneWielis
- Better authentication failure message thanks to @AnneWielis
- Travis PHP compatibility additions thanks again to @AnneWielis (should have had your own release really!)

### Fixed

- Connector has additional gzip encoding and useragent options set via CURLOPT to resolve #51

## [v1.6.0] - 2021-03-02

### Added

- New "mystery" header added to each curl request, required to prevent HTTP 402 responses. Thanks to @pygoubet for this addition, and thanks to @e7andy for identifying the new header

## [v1.5.0] - 2020-09-02

### Added

- Ability to download .fit files in ZIP format (thanks @evanbarter)

## [v1.4.0] - 2020-08-14

### Added

New methods:

- getWorkoutList()
- createWorkout()
- deleteWorkout()
- createStepNote()
- scheduleWorkout()
- getSleepData()

## [v1.3.1] - 2020-02-19

### Fixed

- Compatibilty fixes for PHP 7.2 (thanks @amyboyd)

## [v1.3.0] - 2019-10-23

### Added

- getWellnessData() method now provides the ability to ... get ... wellness ... data :D

## [v1.2.0] - 2019-04-29

### Fixed

- `getActivityTypes()` had it's endpoint URL fixed, so is now working again.

### Added

- Can now call `getActivityList()` with an optional third parameter, which is a string representation of the activity type
that is returned in the `getActivityTypes()` method. README and example updated, please check for instructions.

## [v1.1.2] - 2019-04-29

### Added

- Changelog!

### Fixed

- Some of the endpoint URLs have changed, so have updated them wherever possible.

## [v1.1.1] - 2019-04-27

### Added

- Snooping of _csrf value from login form, and now passing it to login POST
- Additional optional parameter to Connector::post() method, allowing you to pass the referer (required as part of the authentication)

### Changed

- Some general tidy up of coding standards
- Composer refresh

[Unreleased]: https://github.com/dawguk/php-garmin-connect/compare/v1.7.0...HEAD
[v1.7.0]: https://github.com/dawguk/php-garmin-connect/compare/v1.6.0...v1.7.0
[v1.6.0]: https://github.com/dawguk/php-garmin-connect/compare/v1.5.0...v1.6.0
[v1.5.0]: https://github.com/dawguk/php-garmin-connect/compare/v1.4.0...v1.5.0
[v1.4.0]: https://github.com/dawguk/php-garmin-connect/compare/v1.3.1...v1.4.0
[v1.3.1]: https://github.com/dawguk/php-garmin-connect/compare/v1.3.0...v1.3.1
[v1.3.0]: https://github.com/dawguk/php-garmin-connect/compare/v1.2.0...v1.3.0
[v1.2.0]: https://github.com/dawguk/php-garmin-connect/compare/v1.1.2...v1.2.0
[v1.1.2]: https://github.com/dawguk/php-garmin-connect/compare/v1.1.1...v1.1.2
[v1.1.1]: https://github.com/dawguk/php-garmin-connect/compare/v1.1.0...v1.1.1
196 changes: 175 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ $arrCredentials = array(
try {
$objGarminConnect = new \dawguk\GarminConnect($arrCredentials);

$objResults = $objGarminConnect->getActivityList(0, 1);
$objResults = $objGarminConnect->getActivityList(0, 1, 'cycling');
foreach($objResults->results->activities as $objActivity) {
print_r($objActivity->activity);
}
@@ -49,12 +49,21 @@ The library implements a few basic API functions that you can use to retrieve us

| Method | Parameters | Returns |
| ----------------------- | -------------------- | --------------------------- |
| getActivityTypes() | - | stdClass |
| getActivityList() | integer $intStart, integer $intLimit | stdClass |
| getActivityTypes() | - | Array |
| getActivityList() | integer $intStart, integer $intLimit, string $strActivityType | stdClass |
| getActivitySummary() | integer $intActivityID | stdClass |
| getActivityDetails() | integer $intActivityID | stdClass |
| getDataFile | string $strType, integer $intActivityID | string |
| getUsername | - | string |
| getUser | - | string |
| getWellnessData | string $strFrom, string $strTo | string |
| getWeightData | string $strFrom, string $strTo | string |
| getSleepData | | string |
| getWorkoutList | integer $intStart, integer $intLimit, bool $myWorkoutsOnly, bool $sharedWorkoutsOnly | string |
| createWorkout | string $data | string |
| deleteWorkout | integer $id | string |
| createStepNote | integer $stepID, string $note, integer $workoutID | string |
| scheduleWorkout | integer $id, string $payload | string |


### getActivityTypes()

@@ -77,27 +86,28 @@ try {

#### Response

stdClass Object
Array
(
[key] => road_biking
[display] => Road Cycling
[parent] => stdClass Object
(
[key] => cycling
[display] => Cycling
)
[0] => stdClass Object
(
[typeId] => 1
[typeKey] => running
[parentTypeId] => 17
[sortOrder] => 3
)

[1] => stdClass Object
(
[typeId] => 2
[typeKey] => cycling
[parentTypeId] => 17
[sortOrder] => 8
)

[type] => stdClass Object
(
[key] => cycling
[display] => Cycling
)

)

### getActivityList(integer $intStart, integer $intLimit)
### getActivityList(integer $intStart, integer $intLimit, string $strActivityType)

Returns a stdClass object, which contains an array called results, that contains stdClass objects that represents an activity. It accepts two parameters - start and limit; start is the record that you wish to start from, and limit is the number of records that you would like returned.
Returns a stdClass object, which contains an array called results, that contains stdClass objects that represents an activity. It accepts three parameters - start, limit and activity type; start is the record that you wish to start from, limit is the number of records that you would like returned, and activity type is the (optional) string representation of the activity type returned from `getActivityTypes()`

#### Example

@@ -223,6 +233,7 @@ Returns a string representation of requested data type, for the given activity I

|Type | Returns |
|---- | ------- |
|\dawguk\GarminConnect::DATA_TYPE_FIT | Original .fit file, zipped |
|\dawguk\GarminConnect::DATA_TYPE_GPX | GPX as XML string |
|\dawguk\GarminConnect::DATA_TYPE_TCX | TCX as XML string |
|\dawguk\GarminConnect::DATA_TYPE_GOOGLE_EARTH | Google Earth as XML string |
@@ -262,3 +273,146 @@ Returns a string representation of requested data type, for the given activity I
</gpxtpx:TrackPointExtension>
</extensions>

### getWorkoutList(integer $intStart, integer $intLimit, bool $myWorkoutsOnly, bool $sharedWorkoutsOnly)

Returns an array of stdClass objects.

#### Example

```php
try {
$objGarminConnect = new \dawguk\GarminConnect($arrCredentials);
$obj_results = $objGarminConnect->getWorkoutList(0, 10);
print_r($obj_results);
} catch (Exception $objException) {
echo "Oops: " . $objException->getMessage();
}
```

#### Response

```json
[

{
"workoutId": 12345678,
"ownerId": 12345678,
"workoutName": "1.5h run",
"description": null,
"updateDate": "2020-04-20T15:26:05.0",
"createdDate": "2020-04-20T15:26:05.0",
"sportType": {
"sportTypeId": 1,
"sportTypeKey": "running",
"displayOrder": 1
},
"trainingPlanId": null,
"author": {
"userProfilePk": null,
"displayName": null,
"fullName": null,
"profileImgNameLarge": null,
"profileImgNameMedium": null,
"profileImgNameSmall": null,
"userPro": false,
"vivokidUser": false
},
"estimatedDurationInSecs": null,
"estimatedDistanceInMeters": null,
"poolLength": 0.0,
"poolLengthUnit": {
"unitId": null,
"unitKey": null,
"factor": null
},
"workoutProvider": null,
"workoutSourceId": null,
"consumer": null,
"atpPlanId": null,
"workoutNameI18nKey": null,
"descriptionI18nKey": null,
"exerciseCriteria": null,
"shared": false,
"estimated": true
}
]
```

### createWorkout(string $data)

Returns a JSON object of the created workout.

#### Example

```php
try {
$data = '';
$objGarminConnect = new \dawguk\GarminConnect($arrCredentials);
$obj_results = $objGarminConnect->createWorkout($data);
print_r($obj_results);
} catch (Exception $objException) {
echo "Oops: " . $objException->getMessage();
}
```

#### Response

```json
{"workoutId":204516560,"ownerId":80242598,"workoutName":"Testing 1, 2, 3...","description":null,"updatedDate":"2020-04-20T16:06:19.0","createdDate":"2020-04-20T16:06:19.0",...}
```

### deleteWorkout(integer $id)

Deletes a workout from the Garmin website and returns no content.

#### Example

```php
try {
$objGarminConnect = new \dawguk\GarminConnect($arrCredentials);
$obj_results = $objGarminConnect->deleteWorkout(593520370);
print_r($obj_results);
} catch (Exception $objException) {
echo "Oops: " . $objException->getMessage();
}
```

### createStepNote(integer $stepID, string $note, integer $workoutID)

Creates a new note and attaches it to a step. No content is returned from Garmin - 204.

#### Example

```php
try {
$data = '';
$objGarminConnect = new \dawguk\GarminConnect($arrCredentials);
$obj_results = $objGarminConnect->createStepNote(593520370, 'Hello World', 123456789);
print_r($obj_results);
} catch (Exception $objException) {
echo "Oops: " . $objException->getMessage();
}
```

### scheduleWorkout(integer $id, string $data)

Creates a new event on your calendar and returns a JSON object as the response.

#### Example

```php
try {
$data = '';
$objGarminConnect = new \dawguk\GarminConnect($arrCredentials);
$obj_results = $objGarminConnect->scheduleWorkout(593520370, $data);
print_r($obj_results);
} catch (Exception $objException) {
echo "Oops: " . $objException->getMessage();
}
```

#### Response

```json
{"workoutScheduleId":305583643,"workout":{"workoutId":204503966,"ownerId":80242598,"workoutName":"3h run","description":null,"updatedDate":"2020-04-20T15:26:06.0","createdDate":"2020-04-20T15:26:06.0","sportType":{"sportTypeId":1,"sportTypeKey":"running", ...}
```
33 changes: 19 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"name": "dawguk/php-garmin-connect",
"description": "A PHP adapter for interrogating the Garmin Connect \"API\"",
"require": {
"php": ">=5.3.0"
},
"license": "MIT",
"autoload": {
"classmap": [
"src/"
]
},
"include-path": ["src/"]
}
{
"name": "dawguk/php-garmin-connect",
"description": "A PHP adapter for interrogating the Garmin Connect \"API\"",
"require": {
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*"
},
"license": "MIT",
"autoload": {
"classmap": [
"src/"
]
},
"include-path": ["src/"],
"require-dev": {
"squizlabs/php_codesniffer": "2.8.*"
}
}
Loading