Created
September 18, 2020 00:01
-
-
Save ponyjackal/32dc7bbfe52889578602316da7985f4a to your computer and use it in GitHub Desktop.
Twilio Voice conference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add grant to join voice conference (fire event to join voice conference) | |
$voiceToken = new AccessToken( | |
$_ENV['TWILIO_SID'], | |
$_ENV['TWILIO_VIDEO_SID'], | |
$_ENV['TWILIO_VIDEO_SECRET'], | |
3600, | |
$userIdentity | |
); | |
$voiceGrant = new VoiceGrant(); | |
$voiceGrant->setOutgoingApplicationSid($_ENV['TWILIO_APPLICATION_SID']); | |
$voiceGrant->setIncomingAllow(true); | |
$voiceToken->addGrant($voiceGrant); | |
return $this->json([ | |
'token' => $token->toJWT() | |
]); | |
//Return TwiML for voince conference (webhook) | |
$voiceRes = new VoiceResponse(); | |
$dial = $voiceRes->dial(''); | |
$dial->conference( | |
$roomName, | |
[ | |
'waitUrl' => 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient', | |
'maxParticipants' => 4, | |
'record' => 'record-from-start' | |
'statusCallback' => "https://api.safeup.co/v1/getStatusConference", | |
] | |
); | |
$response = new Response( | |
$voiceRes, | |
Response::HTTP_OK, | |
['content-type' => 'text/xml'] | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment