t3mnikov/livekit-sdk-php

LiveKit SFU 的 PHP SDK

0.1.1 2022-06-30 22:22 UTC

This package is auto-updated.

Last update: 2024-09-29 06:14:47 UTC


README

PHP SDK,用于管理房间、出口并创建访问令牌。此包旨在与 livekit-server 一起使用。使用 PHP 后端管理对 LiveKit 的访问。数据交换基于 JSON

安装

要求

  • php: >= 7.2

Composer

composer require t3mnikov/livekit-sdk-php

创建访问令牌

为参与者创建加入房间的令牌。

use T3mnikov\AccessToken;
use T3mnikov\AccessTokenOptions;

$tokenOptions = new AccessTokenOptions();
$tokenOptions->setName('My Name');
$tokenOptions->setIdentity('Anybody');

$accessToken = new AccessToken($apiKey, $secret, $tokenOptions);

$grants = new VideoGrant();
$grants->setRoomName($testRoom);
$grants->setRoomJoin();

$accessToken->addGrant($grants);
echo $token = $accessToken->getToken();

管理房间

接收房间列表。

use T3mnikov\RoomServiceClient;

$host = 'https://my.livekit.host';
$service = new RoomServiceClient($host, 'api-key', 'secret-key');

// List rooms.
$rooms = $service->listRooms();