PHPackages                             sportrizer/sportysky-client-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sportrizer/sportysky-client-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sportrizer/sportysky-client-php
===============================

Sportysky PHP client

2.1.9(6y ago)1471[2 PRs](https://github.com/SportRIZER/sportysky-client-php/pulls)MITPHPPHP ^7.1

Since Jan 25Pushed 3y ago3 watchersCompare

[ Source](https://github.com/SportRIZER/sportysky-client-php)[ Packagist](https://packagist.org/packages/sportrizer/sportysky-client-php)[ RSS](/packages/sportrizer-sportysky-client-php/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (20)Used By (0)

SportySKY PHP client
====================

[](#sportysky-php-client)

**How to integrate SportySKY within your PHP project**

[![Build Status](https://camo.githubusercontent.com/b8788dfbabd3446a9d22527f2442bdab1415dd651a2ffbf3d4c275488e8dc8ba/68747470733a2f2f7472617669732d63692e6f72672f53706f727452495a45522f73706f727479736b792d636c69656e742d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SportRIZER/sportysky-client-php)[![codecov](https://camo.githubusercontent.com/a5b216bd194cacf8664b7d8ec99f5a2cfe2885803ca89e4156e4b206e55baeab/68747470733a2f2f636f6465636f762e696f2f67682f53706f727452495a45522f73706f727479736b792d636c69656e742d7068702f6272616e63682f6d61737465722f6772617068732f62616467652e737667)](https://codecov.io/gh/SportRIZER/sportysky-client-php)

- [Requirements](#requirements)
- [Getting started](#getting-started)
    - [API Client](#api-client)
        - [getCountryForecastResponse](#getcountryforecastresponse)
        - [getRegionForecastResponse](#getregionforecastresponse)
        - [getDepartmentForecastResponse](#getdepartmentforecastresponse)
        - [getSpotForecastResponse](#getspotforecastresponse)
        - [getSpotForecastByCodeAndCountryResponse](#getspotforecastbycodeandcountryresponse)
        - [getSpotsResponse](#getspotsresponse)
        - [getForecastResponse](#getforecastresponse)
    - [Integration with the SportySKY javascript library](#integration-with-the-sportysky-javascript-library)
- [Caching](#caching)
    - [SportySKY API responses](#sportysky-api-responses)
    - [JWT Authentication token](#jwt-authentication-token)
- [Modifications](#modifications)
    - [Modification on API return](#modification-on-api-return)
    - [Modification on API return and caching](#modification-on-api-return-and-caching)
- [Examples](#examples)
- [Testing](#testing)

Requirements
------------

[](#requirements)

- PHP ^7.2
- [Composer](https://getcomposer.org/)

Getting started
---------------

[](#getting-started)

Install the SportySKY PHP client via the composer package manager :

```
composer require sportrizer/sportysky-client-php
```

### API Client

[](#api-client)

---

#### getCountryForecastResponse

[](#getcountryforecastresponse)

Example :

```
$response = $apiClient->getCountryForecastResponse('FR', new \DateTime('2020-01-14T17:36:00+00:00'));
$data = json_decode($response->getBody()->getContents(), true);
```

#### getRegionForecastResponse

[](#getregionforecastresponse)

Example :

```
$response = $apiClient->getRegionForecastResponse('FR-BRE', new \DateTime('2020-01-14T17:36:00+00:00'));
$data = json_decode($response->getBody()->getContents(), true);
```

#### getDepartmentForecastResponse

[](#getdepartmentforecastresponse)

Example :

```
$response = $apiClient->getDepartmentForecastResponse('FR-29', new \DateTime('2020-01-14T17:36:00+00:00'));
$data = json_decode($response->getBody()->getContents(), true);
```

#### getSpotForecastResponse

[](#getspotforecastresponse)

Example :

```
$response = $apiClient->getSpotForecastResponse(
    '1234-1234-1234-1234',
    new \DateTime('2020-01-14T17:36:00+00:00'),
    new \DateTime('2020-01-14T17:36:00+00:00')
);
$data = json_decode($response->getBody()->getContents(), true);
```

#### getSpotForecastByCodeAndCountryResponse

[](#getspotforecastbycodeandcountryresponse)

Example :

```
$response = $apiClient->getSpotForecastByCodeAndCountryResponse(
    '29000',
    'FR',
    new \DateTime('2020-01-14T17:36:00+00:00'),
    new \DateTime('2020-01-14T17:36:00+00:00')
);
$data = json_decode($response->getBody()->getContents(), true);
```

#### getSpotsResponse

[](#getspotsresponse)

Example :

```
use Sportrizer\Sportysky\Utils\Geo\Box;
use Sportrizer\Sportysky\Utils\Geo\Point;

// search nearest spot
$response = $apiClient->getSpotsResponse(
    new Point(33.3, 44.4)
);
$data = json_decode($response->getBody()->getContents(), true);

// find all spots inside a bounding box
$response = $apiClient->getSpotsResponse(
    null,
    new Box(new Point(22.2, 33.3), new Point(33.3, 44.4))
);

// pagination
$response = $apiClient->getSpotsResponse(
    null,
    null,
    3 // get page 3
);

$data = json_decode($response->getBody()->getContents(), true);
```

#### getForecastResponse

[](#getforecastresponse)

Example :

```
$response = $apiClient->getForecastResponse(new \DateTime('2020-01-14T17:36:00+00:00'), null, null, null, 'FR');
$data = json_decode($response->getBody()->getContents(), true);
```

### Integration with the SportySKY javascript library

[](#integration-with-the-sportysky-javascript-library)

---

This library is developed to work seamlessly with the SportySKY javascript library provided by SportRIZER.

Create a php script that will be called by the javascript library :

```
