forked from sadam1807/twilio_integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.php
executable file
·37 lines (30 loc) · 909 Bytes
/
token.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
include('./vendor/autoload.php');
include('./config.php');
include('./randos.php');
use Twilio\Jwt\AccessToken;
use Twilio\Jwt\Grants\VideoGrant;
// An identifier for your app - can be anything you'd like
$appName = 'TwilioVideoDemo';
// choose a random username for the connecting user
$identity = randomUsername();
// Create access token, which we will serialize and send to the client
$token = new AccessToken(
$TWILIO_ACCOUNT_SID,
$TWILIO_API_KEY,
$TWILIO_API_SECRET,
3600,
$identity
);
// Grant access to Video
// $roomName = 'DailyStandhghup';
$grant = new VideoGrant();
//print_r($grant);
// $grant->setConfigurationProfileSid($TWILIO_CONFIGURATION_SID);
// $grant->setRoom($roomName);
$token->addGrant($grant);
// return serialized token and the user's randomly generated ID
echo json_encode(array(
'identity' => $identity,
'token' => $token->toJWT(),
));