yizhou/agora

There is no license information available for the latest version (v1.0.0) of this package.

v1.0.0 2021-08-10 06:23 UTC

This package is auto-updated.

Last update: 2024-10-16 14:38:54 UTC


README

介绍

声网服务端php sdk, 代码来源官网文档。添加了命名空间。

软件架构

psr-4

安装教程

composer require yizhou/agora

使用说明

require_once __DIR__ . '/vendor/autoload.php';
use Agora\RtcTokenBuilder;

$appID = "970CA35de60c44645bbae8a215061b33";
$appCertificate = "5CFd2fd1755d40ecb72977518be15d3b";
$channelName = "7d72365eb983485397e3e3f9d460bdda";
$uid = 2882341273;
$uidStr = "2882341273";
$role = RtcTokenBuilder::RoleAttendee;

$expireTimeInSeconds = 3600;
$currentTimestamp = (new DateTime("now", new DateTimeZone('UTC')))->getTimestamp();
$privilegeExpiredTs = $currentTimestamp + $expireTimeInSeconds;

$token = RtcTokenBuilder::buildTokenWithUid($appID, $appCertificate, $channelName, $uid, $role, $privilegeExpiredTs);
echo 'Token with int uid: ' . $token . PHP_EOL;

$token = RtcTokenBuilder::buildTokenWithUserAccount($appID, $appCertificate, $channelName, $uidStr, $role, $privilegeExpiredTs);
echo 'Token with user account: ' . $token . PHP_EOL;

参与贡献

  1. yizhou