vonage/video

Vonage视频API服务器操作的客户端包

1.1.0 2024-08-14 15:07 UTC

README

Contributor Covenant Build Status Latest Stable Version License codecov

The Vonage logo

此库需要至少PHP版本8.0

这是Vonage视频API的PHP客户端库。它扩展了Vonage PHP库。要使用此库,您需要一个Vonage账户。免费注册[在nexmo.com][signup]。

安装

要使用客户端库,您需要已经[创建一个Vonage账户][signup]。

要将PHP客户端库安装到您的项目中,我们建议使用Composer

composer require vonage/video

请注意,此包不是设计为独立使用的。它需要vonage/client-core包来工作,但您可能没有安装符合PSR-11标准的HTTP客户端,这是必需的。为了解决这个问题,首先安装vonage/client-core,然后安装vonage/video。这将满足包的所有要求。

如果您是Composer的新手,以下是一些您可能认为有用的资源

使用

如果您正在使用Composer,请确保将自动加载器包含在项目启动文件中

require_once "vendor/autoload.php";

使用您的Vonage应用程序ID和私钥创建客户端

use Vonage\Client;
use Vonage\Client\Credentials\Keypair;
use Vonage\Video\ClientFactory;

$credentials = new Keypair('private-key-string', 'application-id');
$client = new Client($credentials);
$vonageVideoClient = $client->video();

为了测试目的,您可以更改客户端请求的API URL,从https://video.api.vonage.com更改为其他地址。为此,在创建Vonage客户端时传递base_video_url选项。

$credentials = new Keypair('private-key-string', 'application-id');
$options = ['base_video_url' => 'https://local-testing.video.example.com'];
$client = new Client($credentials. $options);

示例

创建新会话

$session = $client->video()->createSession();
echo $session->getSessionId();

使用存档创建新会话

use Vonage\Video;
use Vonage\Video\Archive\ArchiveMode;

$session = $client->video()->createSession(new SessionOptions(['archiveMode' => ArchiveMode::ALWAYS]));
echo $session->getSessionId();

生成客户端令牌

$token = $client->video()->generateClientToken($session->getSessionId());

支持的API

以下是一个列表,列出了Vonage视频API以及SDK是否提供了对它们的支持