PHP Class App\services\RESTfulService

Afficher le fichier Open project: phanan/koel Class Usage Examples

Protected Properties

Свойство Type Description
$client Client; The GuzzleHttp client to talk to the API.
$endpoint string The API endpoint.
$key string The API key.
$keyParam string For example, Last.fm use api_key, like this: https://ws.audioscrobbler.com/2.0?method=artist.getInfo&artist=Kamelot&api_key=API_KEY.
$responseFormat
$secret string The API secret.

Méthodes publiques

Méthode Description
__call ( string $method, array $args ) : object Make an HTTP call to the external resource.
__construct ( $key, $secret, $endpoint, Client $client )
buildUrl ( string $uri, boolean $appendKey = true ) : string Turn a URI segment into a full API URL.
getClient ( ) : Client
getEndpoint ( ) : string
getKey ( ) : string
getSecret ( ) : string
request ( string $verb, string $uri, boolean $appendKey = true, array $params = [] ) : object | string Make a request to the API.
setClient ( Client $client )
setEndpoint ( string $endpoint )
setKey ( string $key )
setSecret ( string $secret )

Method Details

__call() public méthode

Make an HTTP call to the external resource.
public __call ( string $method, array $args ) : object
$method string The HTTP method
$args array An array of parameters
Résultat object

__construct() public méthode

public __construct ( $key, $secret, $endpoint, Client $client )
$client GuzzleHttp\Client

buildUrl() public méthode

Turn a URI segment into a full API URL.
public buildUrl ( string $uri, boolean $appendKey = true ) : string
$uri string
$appendKey boolean Whether to automatically append the API key into the URL.
Résultat string

getClient() public méthode

public getClient ( ) : Client
Résultat GuzzleHttp\Client

getEndpoint() public méthode

public getEndpoint ( ) : string
Résultat string

getKey() public méthode

public getKey ( ) : string
Résultat string

getSecret() public méthode

public getSecret ( ) : string
Résultat string

request() public méthode

Make a request to the API.
public request ( string $verb, string $uri, boolean $appendKey = true, array $params = [] ) : object | string
$verb string The HTTP verb
$uri string The API URI (segment)
$appendKey boolean Whether to automatically append the API key into the URI. While it's usually the case, some services (like Last.fm) requires an "API signature" of the request. Appending an API key will break the request.
$params array An array of parameters
Résultat object | string

setClient() public méthode

public setClient ( Client $client )
$client GuzzleHttp\Client

setEndpoint() public méthode

public setEndpoint ( string $endpoint )
$endpoint string

setKey() public méthode

public setKey ( string $key )
$key string

setSecret() public méthode

public setSecret ( string $secret )
$secret string

Property Details

$client protected_oe property

The GuzzleHttp client to talk to the API.
protected Client; $client
Résultat Client;

$endpoint protected_oe property

The API endpoint.
protected string $endpoint
Résultat string

$key protected_oe property

The API key.
protected string $key
Résultat string

$keyParam protected_oe property

For example, Last.fm use api_key, like this: https://ws.audioscrobbler.com/2.0?method=artist.getInfo&artist=Kamelot&api_key=API_KEY.
protected string $keyParam
Résultat string

$responseFormat protected_oe property

protected $responseFormat

$secret protected_oe property

The API secret.
protected string $secret
Résultat string