【发布时间】:2021-03-14 03:38:04
【问题描述】:
基本上我是 Laravel 的后端开发人员。我想使用 Twilio 为视频通话创建 accessToken,前端是移动应用(Flutter),后端是 Laravel。
【问题讨论】:
基本上我是 Laravel 的后端开发人员。我想使用 Twilio 为视频通话创建 accessToken,前端是移动应用(Flutter),后端是 Laravel。
【问题讨论】:
这里是 Twilio 开发者宣传员。
As mentioned in these docs,可以生成访问令牌
在 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 应用程序的外观,您可能能够执行类似 I did in JavaScript here with the Twilio CLI 的操作。
如果这有帮助,请告诉我!
【讨论】:
composer install吗? stackoverflow.com/questions/41209349/…