0

Outbound Calls in For Loop

Hi,

I'm trying to get my application to perform outbound calls based on a list of phone numbers in a database.

 

First, the user uses an html form to submit a message to be communicated. That form is posted by an ajax request to a php file that acts as a form controller. 

The form controller then queries the database for a list of phone numbers.  

What is the proper syntax for placing the calls in a php file? It seems like the WebApi always wants to return JSON. 

From the user's perspective, the form page should never change with the exception of a "success" message. 

 

I have tried two ways so far just to try to establish functionality.

(all libraries included earlier in code)

First way, without limonade:

if(count($cellList) >= 1) {

foreach ($cellList as $row) {
error_log(date('[Y-m-d H:i e] '). "Calling: ". $row['cell'] . " with message: " . $_POST['alertMsg'] . PHP_EOL, 3, RFFLR_LOG_FILE);

$tropo = new Tropo();

$tropo->call("+14129130651");
$tropo->say("Tag, you're it!");
$tropo->RenderJson();

}

}

Second way, with limonade:

if(count($cellList) >= 1) {

foreach ($cellList as $row) {
error_log(date('[Y-m-d H:i e] '). "Calling: ". $row['cell'] . " with message: " . $_POST['alertMsg'] . PHP_EOL, 3, RFFLR_LOG_FILE);

dispatch_post('/start', 'app_start');
function app_start() {

$tropo = new Tropo();

$tropo->call("4129130651");
$tropo->say("Tag, you're it!");

//$tropo->on(array("event" => "incomplete", "next" => "hello_world.php?uri=incomplete"));

return $tropo->RenderJson();

}

dispatch_post('/incomplete', 'app_incomplete');
function app_incomplete() {
error_log(date('[Y-m-d H:i e] '). "The call did not complete" . PHP_EOL, 3, LOG_FILE);
}

run();
}

}

 

Neither way works.

2 comments

Please sign in to leave a comment.