PHP Class Iamstuartwilson\StravaApi

Afficher le fichier Open project: iamstuartwilson/strava Class Usage Examples

Méthodes publiques

Свойство Type Description
$lastRequest
$lastRequestData
$lastRequestInfo

Protected Properties

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
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

Method Details

__construct() public méthode

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

authenticationUrl() public méthode

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
Résultat string

deauthorize() public méthode

Deauthorises application
public deauthorize ( ) : string
Résultat string

delete() public méthode

Sends DELETE request to specified API endpoint
public delete ( string $request, array $parameters = [] ) : string
$request string
$parameters array
Résultat string

generateParameters() protected méthode

Adds access token to paramters sent to API
protected generateParameters ( array $parameters ) : array
$parameters array
Résultat array

get() public méthode

Sends GET request to specified API endpoint
public get ( string $request, array $parameters = [] ) : string
$request string
$parameters array
Résultat string

getResponseHeader() public méthode

public getResponseHeader ( string $header ) : string
$header string
Résultat string

getResponseHeaders() public méthode

Returns the complete list of response headers.
public getResponseHeaders ( ) : array
Résultat array

parseGet() protected méthode

Appends query array onto URL
protected parseGet ( string $url, array $query ) : string
$url string
$query array
Résultat string

parseHeader() protected méthode

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
Résultat integer length of the currently parsed header line in bytes

parseResponse() protected méthode

Parses JSON as PHP object
protected parseResponse ( string $response ) : object
$response string
Résultat object

post() public méthode

Sends POST request to specified API endpoint
public post ( string $request, array $parameters = [] ) : string
$request string
$parameters array
Résultat string

put() public méthode

Sends PUT request to specified API endpoint
public put ( string $request, array $parameters = [] ) : string
$request string
$parameters array
Résultat string

request() protected méthode

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
Résultat mixed

setAccessToken() public méthode

Sets the access token used to authenticate API requests
public setAccessToken ( string $token ) : string
$token string
Résultat string

tokenExchange() public méthode

Authenticates token returned from API
public tokenExchange ( string $code ) : string
$code string
Résultat string

Property Details

$apiUrl protected_oe property

protected $apiUrl

$authUrl protected_oe property

protected $authUrl

$clientId protected_oe property

protected $clientId

$clientSecret protected_oe property

protected $clientSecret

$lastRequest public_oe property

public $lastRequest

$lastRequestData public_oe property

public $lastRequestData

$lastRequestInfo public_oe property

public $lastRequestInfo

$responseHeaders protected_oe property

[ '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
Résultat array