PHP Класс Iamstuartwilson\StravaApi

Автор: Stuart Wilson ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$lastRequest
$lastRequestData
$lastRequestInfo

Защищенные свойства (Protected)

Свойство Тип Описание
$apiUrl
$authUrl
$clientId
$clientSecret
$responseHeaders array [ 'Cache-Control' => 'max-age=0, private, must-revalidate', 'X-RateLimit-Limit' => '600,30000', 'X-RateLimit-Usage' => '4,25', 'Content-Length' => '2031', ... ] Access with the getResponseHeader() or getResponseHeaders() methods.

Открытые методы

Метод Описание
__construct ( integer $clientId = 1, string $clientSecret = '' ) Sets up the class with the $clientId and $clientSecret
authenticationUrl ( string $redirect, string $approvalPrompt = 'auto', string $scope = null, string $state = null ) : string Creates authentication URL for your app
deauthorize ( ) : string Deauthorises application
delete ( string $request, array $parameters = [] ) : string Sends DELETE request to specified API endpoint
get ( string $request, array $parameters = [] ) : string Sends GET request to specified API endpoint
getResponseHeader ( string $header ) : string
getResponseHeaders ( ) : array Returns the complete list of response headers.
post ( string $request, array $parameters = [] ) : string Sends POST request to specified API endpoint
put ( string $request, array $parameters = [] ) : string Sends PUT request to specified API endpoint
setAccessToken ( string $token ) : string Sets the access token used to authenticate API requests
tokenExchange ( string $code ) : string Authenticates token returned from API

Защищенные методы

Метод Описание
generateParameters ( array $parameters ) : array Adds access token to paramters sent to API
parseGet ( string $url, array $query ) : string Appends query array onto URL
parseHeader ( resource $curl, string $headerLine ) : integer Parses the header lines into the $responseHeaders attribute
parseResponse ( string $response ) : object Parses JSON as PHP object
request ( string $url, array $parameters = [], boolean | string $request = false ) : mixed Makes HTTP Request to the API

Описание методов

__construct() публичный Метод

Sets up the class with the $clientId and $clientSecret
public __construct ( integer $clientId = 1, string $clientSecret = '' )
$clientId integer
$clientSecret string

authenticationUrl() публичный Метод

Creates authentication URL for your app
public authenticationUrl ( string $redirect, string $approvalPrompt = 'auto', string $scope = null, string $state = null ) : string
$redirect string
$approvalPrompt string
$scope string
$state string
Результат string

deauthorize() публичный Метод

Deauthorises application
public deauthorize ( ) : string
Результат string

delete() публичный Метод

Sends DELETE request to specified API endpoint
public delete ( string $request, array $parameters = [] ) : string
$request string
$parameters array
Результат string

generateParameters() защищенный Метод

Adds access token to paramters sent to API
protected generateParameters ( array $parameters ) : array
$parameters array
Результат array

get() публичный Метод

Sends GET request to specified API endpoint
public get ( string $request, array $parameters = [] ) : string
$request string
$parameters array
Результат string

getResponseHeader() публичный Метод

public getResponseHeader ( string $header ) : string
$header string
Результат string

getResponseHeaders() публичный Метод

Returns the complete list of response headers.
public getResponseHeaders ( ) : array
Результат array

parseGet() защищенный Метод

Appends query array onto URL
protected parseGet ( string $url, array $query ) : string
$url string
$query array
Результат string

parseHeader() защищенный Метод

Skips the first header line (HTTP response status) and the last header line (empty).
protected parseHeader ( resource $curl, string $headerLine ) : integer
$curl resource
$headerLine string
Результат integer length of the currently parsed header line in bytes

parseResponse() защищенный Метод

Parses JSON as PHP object
protected parseResponse ( string $response ) : object
$response string
Результат object

post() публичный Метод

Sends POST request to specified API endpoint
public post ( string $request, array $parameters = [] ) : string
$request string
$parameters array
Результат string

put() публичный Метод

Sends PUT request to specified API endpoint
public put ( string $request, array $parameters = [] ) : string
$request string
$parameters array
Результат string

request() защищенный Метод

Makes HTTP Request to the API
protected request ( string $url, array $parameters = [], boolean | string $request = false ) : mixed
$url string
$parameters array
$request boolean | string the request method, default is POST
Результат mixed

setAccessToken() публичный Метод

Sets the access token used to authenticate API requests
public setAccessToken ( string $token ) : string
$token string
Результат string

tokenExchange() публичный Метод

Authenticates token returned from API
public tokenExchange ( string $code ) : string
$code string
Результат string

Описание свойств

$apiUrl защищенное свойство

protected $apiUrl

$authUrl защищенное свойство

protected $authUrl

$clientId защищенное свойство

protected $clientId

$clientSecret защищенное свойство

protected $clientSecret

$lastRequest публичное свойство

public $lastRequest

$lastRequestData публичное свойство

public $lastRequestData

$lastRequestInfo публичное свойство

public $lastRequestInfo

$responseHeaders защищенное свойство

[ 'Cache-Control' => 'max-age=0, private, must-revalidate', 'X-RateLimit-Limit' => '600,30000', 'X-RateLimit-Usage' => '4,25', 'Content-Length' => '2031', ... ] Access with the getResponseHeader() or getResponseHeaders() methods.
protected array $responseHeaders
Результат array