willywes / agora-sdk-php

v0.1.3 2022-04-28 20:52 UTC

This package is auto-updated.

Last update: 2024-08-29 01:43:30 UTC


README

Latest Version on Packagist Total Downloads Build Status StyleCI

PHP SDK Agora.io (非官方) 令牌生成器

安装

通过 Composer

$ composer require willywes/agora-sdk-php

使用方法

use Willywes\AgoraSDK\RtcTokenBuilder;

class AgoraHelper
{
    public static function GetToken($user_id){
    
        $appID = "72fc...";
        $appCertificate = "72fc...";
        $channelName = "Test";
        $uid = $user_id;
        $uidStr = ($user_id) . '';
        $role = RtcTokenBuilder::RoleAttendee;
        $expireTimeInSeconds = 3600;
        $currentTimestamp = (new \DateTime("now", new \DateTimeZone('UTC')))->getTimestamp();
        $privilegeExpiredTs = $currentTimestamp + $expireTimeInSeconds;
    
        return RtcTokenBuilder::buildTokenWithUid($appID, $appCertificate, $channelName, $uid, $role, $privilegeExpiredTs);
    
    }
}
    $user = auth()->user();
    $agora_token = AgoraHelper::GetToken($user->id);

致谢

许可协议

许可协议。请参阅许可文件以获取更多信息。