willywes / agora-sdk-php
Agora.io SDK PHP
Installs: 16 782
Dependents: 2
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 4
Open Issues: 1
Requires
- illuminate/support: ~7|~8|~9
Requires (Dev)
- orchestra/testbench: ~5|~6
- phpunit/phpunit: ~9.0
This package is auto-updated.
Last update: 2024-10-29 02:02:24 UTC
README
PHP SDK Agora.io (unofficial) Token Generator
Installation
Via Composer
$ composer require willywes/agora-sdk-php
Usage
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);
Credits
License
license. Please see the license file for more information.