Skip to content

Instantly share code, notes, and snippets.

@ponyjackal
Created September 18, 2020 00:01
Show Gist options
  • Save ponyjackal/32dc7bbfe52889578602316da7985f4a to your computer and use it in GitHub Desktop.
Save ponyjackal/32dc7bbfe52889578602316da7985f4a to your computer and use it in GitHub Desktop.
Twilio Voice conference
// 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