Basically I'm backend developer of Laravel. I want to create accessToken
for video call using Twilio, front-end is mobile app (Flutter) backend is Laravel.
Asked
Active
Viewed 436 times
0

Don't Panic
- 13,965
- 5
- 32
- 51
1 Answers
3
Twilio developer evangelist here.
As mentioned in these docs, you can generate an access token
In PHP, that'd look like
<?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();
Depending on what your Twilio Video app looks like, you may be able to do something like what I did in JavaScript here with the Twilio CLI.
Let me know if this helps at all!

lizziepika
- 3,231
- 1
- 14
- 23
-
(require_once '/path/to/vendor/autoload.php') main(): Failed opening required 'vendor/autoload.php' (include_path='\xampp\php\PEAR') – bc160200929 Muhammad Noaman Dec 02 '20 at 10:27
-
Do you need to run `composer install`? https://stackoverflow.com/questions/41209349/requirevendor-autoload-php-failed-to-open-stream – lizziepika Dec 02 '20 at 21:12