【问题标题】:How can create access token for Twilio video conference如何为 Twilio 视频会议创建访问令牌
【发布时间】:2021-03-14 03:38:04
【问题描述】:

基本上我是 Laravel 的后端开发人员。我想使用 Twilio 为视频通话创建 accessToken,前端是移动应用(Flutter),后端是 Laravel。

【问题讨论】:

    标签: laravel twilio


    【解决方案1】:

    这里是 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 的操作。

    如果这有帮助,请告诉我!

    【讨论】:

    • (require_once '/path/to/vendor/autoload.php') main(): 未能打开所需的'vendor/autoload.php' (include_path='\xampp\php\PEAR')
    • 你需要运行composer install吗? stackoverflow.com/questions/41209349/…
    猜你喜欢
    • 1970-01-01
    • 2018-03-10
    • 1970-01-01
    • 1970-01-01
    • 2011-10-22
    • 1970-01-01
    • 2017-04-02
    • 2016-12-07
    • 1970-01-01
    相关资源
    最近更新 更多