I am trying to get twilio to point to a method in order to start a call. When I have my twimlApp pointing to www.example.com/twilio/dial.php
I am able to make calls no problem, however when I have it pointing to a controller method www.example.com/twilioApps/dial
I receive a 404 error when looking at the Twilio App Monitor.
Here is twilioApps/index.php
:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
session_cache_limiter(false);
session_start();
require_once __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../twilio.php';
$app = new \Slim\Slim();
$app->get('/dial', function (){
$twilioObj = new twilioPlugin;
// get the phone number from the page request parameters, if given
if (isset($_REQUEST['tocall'])) {
$twilioObj->number = htmlspecialchars($_REQUEST['tocall']);
}
// wrap the phone number or client name in the appropriate TwiML verb
// by checking if the number given has only digits and format symbols
if (preg_match("/^[\d\+\-\(\) ]+$/", $twilioObj->number)) {
$numberOrClient = "<Number>" . $twilioObj->number . "</Number>";
} else {
$numberOrClient = "<Client>" . $twilioObj->clientName . "</Client>";
}
?>
<Response>
<Dial callerId="<?php echo $twilioObj->callerId ?>">
<?php echo $numberOrClient ?>
</Dial>
</Response>
<?php
});
$app->run();
I do not know whether this is a Slim problem, .htaccess problem, or a Twilio issue. Any help is appreciated.
Alright so I figured it out, it was the fact that I had the TwimlApp using a POST request in order to send the number to call. However the type of route I was using in slim was a GET, all I had to do was change the Twiml App request method to GET and it worked fine.