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

4.1 KiB

Sessions

Overview

API Calls that perform search operations with Plex Media Server Sessions

Available Operations

getSessions

This will retrieve the "Now Playing" Information of the PMS.

Example Usage

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

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

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

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

try {
    $response = $sdk->sessions->getSessions();

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

Response

?\LukeHagar\Plex_API\Models\Operations\GetSessionsResponse

getSessionHistory

This will Retrieve a listing of all history views.

Example Usage

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

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

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

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

try {
    $response = $sdk->sessions->getSessionHistory();

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

Response

?\LukeHagar\Plex_API\Models\Operations\GetSessionHistoryResponse

getTranscodeSessions

Get Transcode Sessions

Example Usage

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

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

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

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

try {
    $response = $sdk->sessions->getTranscodeSessions();

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

Response

?\LukeHagar\Plex_API\Models\Operations\GetTranscodeSessionsResponse

stopTranscodeSession

Stop a Transcode Session

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;

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

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

try {
    

    $response = $sdk->sessions->stopTranscodeSession('zz7llzqlx8w9vnrsbnwhbmep');

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

Parameters

Parameter Type Required Description Example
sessionKey string ✔️ the Key of the transcode session to stop zz7llzqlx8w9vnrsbnwhbmep

Response

?\LukeHagar\Plex_API\Models\Operations\StopTranscodeSessionResponse