Setting Up the HTTP Client
All server-side calls to the Frisbii Media API are standard HTTPS requests. The examples in this documentation use Guzzle, but any HTTP client works — including Symfony's HttpClient or plain cURL.
Install Guzzle
Follow the Guzzle installation guide. With Composer:
composer require guzzlehttp/guzzle
Initialise the client
Set the base_uri to the Frisbii Media REST API. Use the stage URL during development, the production URL for live traffic.
Stage:
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.frisbii-media-stage.com/api/v3.0/'
]);
Production:
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.frisbii-media.com/api/v3.0/'
]);
See Environments: Stage vs. Production for a full comparison.
Authentication header
Every request must include the X-plenigo-token header containing a freshly signed JWT. See Authentication & API Tokens for how to generate this token.
Pass it per request:
$response = $client->request('POST', 'customers', [
'headers' => ['X-plenigo-token' => eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9],
'json' => $payload,
]);
Or set it as a client default if all requests share the same token:
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.frisbii-media.com/api/v3.0/',
'headers' => ['X-plenigo-token' => eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9],
]);
The placeholder token
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...that appears throughout the code examples in this documentation is for illustration only and will not work against the API. Always pass a token you generated yourself.
Error handling
Guzzle throws a GuzzleHttp\Exception\ClientException for 4xx responses and a GuzzleHttp\Exception\ServerException for 5xx responses. Always wrap API calls in a try/catch:
try {
$response = $client->request('GET', "accessRights/{$customerId}/hasAccess?accessRightUniqueIds=my-product", [
'headers' => ['X-plenigo-token' => eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9],
]);
$result = json_decode($response->getBody()->getContents());
} catch (\GuzzleHttp\Exception\ClientException $e) {
// 404: resource not found — handle as no-access or not-found
$result = null;
}
For more on Guzzle exceptions, see the Guzzle documentation.