Files
plexphp/docs/sdks/plex/README.md

8.2 KiB
Raw Blame History

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 'vendor/autoload.php';

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

$sdk = Plex_API\PlexAPI::builder()
    ->setXPlexClientIdentifier('<value>')
    ->build();

try {
    

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

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

Parameters

Parameter Type Required Description
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
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\GetPinResponse

getToken

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

Example Usage

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

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

$sdk = Plex_API\PlexAPI::builder()
    ->setXPlexClientIdentifier('<value>')
    ->build();

try {
    

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

    if ($response->statusCode === 200) {
        // handle response
    }
} catch (Throwable $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