基本上我是 Laravel 的后端开发人员。我想accessToken
使用 Twilio 创建视频通话,前端是移动应用程序(Flutter),后端是 Laravel。
1 回答
3
Twilio 开发人员布道者在这里。
如这些文档中所述,您可以生成访问令牌
在 PHP 中,这看起来像
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Jwt\AccessToken;
use Twilio\Jwt\Grants\VideoGrant;
// Required for all Twilio access tokens
$twilioAccountSid = 'ACxxxxxxxxxxxx';
$twilioApiKey = 'SKxxxxxxxxxxxx';
$twilioApiSecret = 'xxxxxxxxxxxxxx';
// A unique identifier for this user
$identity = "alice";
// The specific Room we'll allow the user to access
$roomName = 'DailyStandup';
// Create access token, which we will serialize and send to the client
$token = new AccessToken($twilioAccountSid, $twilioApiKey, $twilioApiSecret, 3600, $identity);
// Create Video grant
$videoGrant = new VideoGrant();
$videoGrant->setRoom($roomName);
// Add grant to token
$token->addGrant($videoGrant);
// render token to string
echo $token->toJWT();
根据您的 Twilio Video 应用程序的外观,您可以使用 Twilio CLI 执行我在 JavaScript 中所做的操作。
让我知道这是否有帮助!
于 2020-12-02T07:59:05.183 回答