Files
plexphp/docs/sdks/plex

Plex

Overview

API Calls that perform operations directly against https://Plex.tv

Available Operations

getPin

Retrieve a Pin from Plex.tv for authentication flows

Example Usage

<?php

declare(strict_types=1);
require_once 'vendor/autoload.php';

use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
use \LukeHagar\Plex_API\Models\Operations;

$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';

$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();

try {
    

    $response = $sdk->plex->getPin('string', false);

    if ($response->twoHundredApplicationJsonObject !== null) {
        // handle response
    }
} catch (Exception $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
xPlexClientIdentifier string ✔️ The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
strong bool Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for Plex.tv/link
$serverURL string An optional server URL to use.

Response

?\LukeHagar\Plex_API\Models\Operations\GetPinResponse

getToken

Retrieve an Access Token from Plex.tv after the Pin has already been authenticated

Example Usage

<?php

declare(strict_types=1);
require_once 'vendor/autoload.php';

use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
use \LukeHagar\Plex_API\Models\Operations;

$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';

$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();

try {
    

    $response = $sdk->plex->getToken('string', 'string');

    if ($response->statusCode === 200) {
        // handle response
    }
} catch (Exception $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
pinID string ✔️ The PinID to retrieve an access token for
xPlexClientIdentifier string ✔️ The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
$serverURL string An optional server URL to use.

Response

?\LukeHagar\Plex_API\Models\Operations\GetTokenResponse