define("ALERTD_CDYNE_LICENSE_KEY", 'secretKeyHere');
define("ALERTD_POST_STATUS_URL", 'https://www.example.com/callback-URL/');
define("ALERTD_CALLER_ID_NUMBER", '6175551212'); // caller id "from" number
define("ALERTD_CALLER_ID_NAME", 'Example.com');
try {
$queueID = phone_notify_queueCall('6175551234', 'Test');
print "OK QueueID=$queueID";
}
catch (Exception $e) {
print "ERROR " . $e->getMessage();
}
*/
/** Queue a phone call to a given number. Returns the CDYNE queue ID, or throws an exception if the call is not queued successfully. */
function phone_notify_queueCall($phoneNumber, $message) {
$message = "~\SetVar(maxcallseconds|120)~
~\StatusChangePostURL(" . ALERTD_POST_STATUS_URL . ")~ "
. $message .
" Press any key to confirm you have received this message.
~\GetDigits(UserConfirmation|4)~
Thank you. Goodbye.
~\EndCall()~
";
try {
$client = new SoapClient('http://ws.cdyne.com/NotifyWS/PhoneNotify.asmx?wsdl');
$result = $client->NotifyPhoneAdvanced( new CallRequestData($phoneNumber, $message) );
$ResponseCode = $result->NotifyPhoneAdvancedResult->ResponseCode;
$ResponseText = $result->NotifyPhoneAdvancedResult->ResponseText;
$queueID = $result->NotifyPhoneAdvancedResult->QueueID;
if ($ResponseCode == '0' || $ResponseText == 'Queued') {
var_dump( $client->GetQueueIDStatusWithAdvancedInfo( new GetQueueIDStatusData($queueID) ) );
return $queueID;
}
throw new Exception("Service returned queueing error: ResponseCode=$ResponseCode; ResponseText=$ResponseText");
} catch (Exception $e) {
// This will catch SOAP exceptions as well.
throw new Exception("Unable to queue call: " . $e->getMessage());
}
}
/** Parameters for CDYNE CallRequestData call */
class CallRequestData {
public $anr;
function CallRequestData($number,$text) {
$this->anr = array();
$this->anr['PhoneNumberToDial'] = $number;
$this->anr['TextToSay'] = $text;
$this->anr['LicenseKey'] = ALERTD_CDYNE_LICENSE_KEY;
$this->anr['CallerIDNumber'] = ALERTD_CALLER_ID_NUMBER;
$this->anr['CallerIDName'] = ALERTD_CALLER_ID_NAME;
$this->anr['StatusChangePostUrl'] = ALERTD_POST_STATUS_URL;
$this->anr['TransferNumber'] = '';
$this->anr['NextTryInSeconds'] = 180;
$this->anr['MaxCallLength'] = 120;
$this->anr['TryCount'] = 5;
$this->anr['TTSvolume'] = 100;
$this->anr['TTSrate'] = 25;
$this->anr['UTCScheduledDateTime'] = '1970-01-01T00:00:00Z';
$this->anr['VoiceID'] = 1;
}
}
/** Parameters for CDYNE GetQueueIDStatus call */
class GetQueueIDStatusData {
public $QueueID;
public $LicenseKey;
function GetQueueIDStatusData($id) {
$this->QueueID = $id;
$this->LicenseKey = ALERTD_CDYNE_LICENSE_KEY;
}
}
define("ALERTD_CDYNE_LICENSE_KEY", 'secretKeyHere');
define("ALERTD_CALLER_ID_NUMBER", '6175551212'); // caller id "from" number
define("ALERTD_CALLER_ID_NAME", 'Example.com');
$client = new SoapClient('http://ws.cdyne.com/NotifyWS/PhoneNotify.asmx?wsdl');
print_r($client);
//Get contents of the file
$handle = fopen("mywavfile.wav", "r");
$contents = fread($handle, filesize("mywavfile.wav"));
fclose($handle);
//Set Parameters
$params = array();
$params['LicenseKey'] = ALERTD_CDYNE_LICENSE_KEY;
$params['SoundFileID'] = 'test1';
$params['FileBinary'] = $contents;
//Make Call
$result = $client->UploadSoundFile( $params );
//Print Result
print_r($result);