forked from twilio/voice-quickstart-server-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeCall.php
More file actions
40 lines (36 loc) · 1.1 KB
/
Copy pathmakeCall.php
File metadata and controls
40 lines (36 loc) · 1.1 KB
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
38
39
40
<?php
/*
* Creates an endpoint that can be used in your TwiML App as the Voice Request Url.
*
* In order to make an outgoing call using Twilio Voice SDK, you need to provide a
* TwiML App SID in the Access Token. You can run your server, make it publicly
* accessible and use `/makeCall` endpoint as the Voice Request Url in your TwiML App.
*/
include('./vendor/autoload.php');
include('./config.php');
$callerId = 'client:quick_start';
$to = isset($_POST["to"]) ? $_POST["to"] : "";
if (!isset($to) || empty($to)) {
$to = isset($_GET["to"]) ? $_GET["to"] : "";
}
/*
* Use a valid Twilio number by adding to your account via https://www.twilio.com/console/phone-numbers/verified
*/
$callerNumber = '1234567890';
$response = new Twilio\Twiml();
if (!isset($to) || empty($to)) {
$response->say('Congratulations! You have just made your first call! Good bye.');
} else if (is_numeric($to)) {
$dial = $response->dial(
array(
'callerId' => $callerNumber
));
$dial->number($to);
} else {
$dial = $response->dial(
array(
'callerId' => $callerId
));
$dial->client($to);
}
print $response;