Initiating an IVR Call Immediately
<?php
use CallFire \Api \Rest \Request ;
use CallFire \Api \Rest \Response ;
require 'vendor/autoload.php ' ;
$ dialplan = <<<DIALPLAN
<dialplan><play type="tts">Congratulations! You have successfully configured a CallFire I V R.</play></dialplan>
DIALPLAN ;
$ client = CallFire \Api \Client ::Rest ("<api-login> " , "<api-password> " , "Call " );
$ request = new Request \SendCall ;
$ request ->setType ($ client ::BROADCAST_IVR );
$ request ->setFrom ('15551231234 ' );
$ request ->setTo ('15551231235 ' );
$ request ->setDialplanXml ($ dialplan );
$ response = $ client ->SendCall ($ request );
$ result = $ client ::response ($ response );
if ($ result instanceof Response \ResourceReference ) {
// Success
}
Initiating a Voice Call Immediately
<?php
use CallFire \Api \Rest \Request ;
use CallFire \Api \Rest \Response ;
require 'vendor/autoload.php ' ;
$ soundId = <existing-sound-id>;
$ client = CallFire \Api \Client ::Rest ("<api-login> " , "<api-password> " , "Call " );
$ request = new Request \SendCall ;
$ request ->setType ($ client ::BROADCAST_VOICE );
$ request ->setFrom ('15551231234 ' );
$ request ->setTo ('15551231235 ' );
$ request ->setAnsweringMachineConfig ($ client ::AMCONFIG_LIVE_IMMEDIATE );
$ request ->setLiveSoundId ($ soundId );
$ response = $ client ->SendCall ($ request );
$ result = $ client ::response ($ response );
if ($ result instanceof Response \ResourceReference ) {
// Success
}
List Incoming Calls For a Number
<?php
use CallFire \Api \Rest \Request ;
use CallFire \Api \Rest \Response ;
require 'vendor/autoload.php ' ;
$ client = CallFire \Api \Client ::Rest ("<api-login> " , "<api-password> " , "Call " );
$ request = new Request \QueryCalls ;
$ request ->setInbound (true );
$ request ->setToNumber ('15551231234 ' );
$ response = $ client ->QueryCalls ($ request );
$ result = $ client ::response ($ response );
if ($ result instanceof Response \ResouceList ) {
foreach ($ result as $ call ) {
$ callRecords = $ call ->getCallRecords ();
$ callRecord = reset ($ callRecords );
echo "[ {$ call ->getCreated ()}] {$ call ->getFromNumber ()}: {$ call ->getMessage ()}" .PHP_EOL ;
}
}