| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace Easemob\Agora;
- /**
- * @ignore
- */
- class ChatTokenBuilder2
- {
- /**
- * Build the CHAT token.
- *
- * @param $appId : The App ID issued to you by Agora. Apply for a new App ID from
- * Agora Dashboard if it is missing from your kit. See Get an App ID.
- * @param $appCertificate : Certificate of the application that you registered in
- * the Agora Dashboard. See Get an App Certificate.
- * @param $userId : The user's unique id.
- * @param $expire : represented by the number of seconds elapsed since now. If, for example, you want to access the
- * Agora Service within 10 minutes after the token is generated, set expireTimestamp as 600(seconds).
- * @return The CHAT token.
- */
- public static function buildUserToken($appId, $appCertificate, $userId, $expire)
- {
- $accessToken = new AccessToken2($appId, $appCertificate, $expire);
- $serviceChat = new ServiceChat($userId);
- $serviceChat->addPrivilege($serviceChat::PRIVILEGE_USER, $expire);
- $accessToken->addService($serviceChat);
- return $accessToken->build();
- }
- /**
- * Build the CHAT token.
- *
- * @param $appId : The App ID issued to you by Agora. Apply for a new App ID from
- * Agora Dashboard if it is missing from your kit. See Get an App ID.
- * @param $appCertificate : Certificate of the application that you registered in
- * the Agora Dashboard. See Get an App Certificate.
- * @param $expire : represented by the number of seconds elapsed since now. If, for example, you want to access the
- * Agora Service within 10 minutes after the token is generated, set expireTimestamp as 600(seconds).
- * @return The CHAT token.
- */
- public static function buildAppToken($appId, $appCertificate, $expire)
- {
- $accessToken = new AccessToken2($appId, $appCertificate, $expire);
- $serviceChat = new ServiceChat();
- $serviceChat->addPrivilege($serviceChat::PRIVILEGE_APP, $expire);
- $accessToken->addService($serviceChat);
- return $accessToken->build();
- }
- }
|