Created
July 31, 2013 16:17
-
-
Save callemall/6123523 to your computer and use it in GitHub Desktop.
This example creates and launches a simple text-to-speech broadcast using the ExtCreateBroadcast function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ===================== | |
// account information | |
// ===================== | |
$username = "999111999"; | |
$pin = "9991"; | |
// ===================== | |
// 1 = Announcement | |
// 2 = Survey | |
// 3 = SMS | |
// ===================== | |
$broadcast_type = "1"; | |
// ================================= | |
// 1 = listID | |
// 2 = CSV Binary attachment | |
// 3 = CommaDelimited Phonenumbers | |
// ================================= | |
$phone_number_source = "3"; | |
// ===================== | |
// Name of the broadcast | |
// ===================== | |
$broadcast_name = "SAMPLE API Broadcast with TTS"; | |
// ======================================== | |
// leave blank to use default from account | |
// ======================================== | |
$caller_id = "9725551212"; | |
// ============================================================================================== | |
// Phonenumbers to call or text (for text/SMS people have to Opt-In to receive) | |
// | |
// Extended usage: phonenumber|firstname|lastname|notes|secondaryPhone|tertiaryPhone> | |
// | |
// ex "9725551212|Grandma|Moses|Some notes here|9725552300,9725552300|test|number,9725554536" | |
// ============================================================================================== | |
$PhoneNumbers = "9725551313, 9725551212, 9305551212"; | |
// =========================================== | |
// Use Text to Speech to generate the message | |
// =========================================== | |
$TTSText = "This is a test of creating a broadcast with text to speech."; | |
$proxy = "http://staging-api.call-em-all.com/webservices/ceaapi_v2.asmx?WSDL"; | |
$client = new SoapClient($proxy, array("trace" => true)); | |
$request = array ( | |
"username" => $username, | |
"pin" => $pin, | |
"broadcastType" => $broadcast_type, | |
"phoneNumberSource" => $phone_number_source, | |
"broadcastName" => $broadcast_name, | |
"phoneNumberCSV" => "", | |
"launchDateTime" => "", | |
"checkCallingWindow" => "0", | |
"callerID" => $caller_id, | |
"commaDelimitedPhoneNumbers" => $PhoneNumbers, | |
"TTSText" => $TTSText, | |
); | |
$response = $client->ExtCreateBroadcast(array("myRequest" => $request)); | |
// ===================== | |
// var_dump($response); | |
// ===================== | |
print "errorCode :" . $response->ExtCreateBroadcastResult->errorCode . "\n"; | |
print "errorMessage :" . $response->ExtCreateBroadcastResult->errorMessage . "\n"; | |
print "broadcastID :" . $response->ExtCreateBroadcastResult->broadcastID . "\n"; | |
print "messageRecordingID :" . $response->ExtCreateBroadcastResult->messageRecordingID . "\n"; | |
print "tollFreeNumber :" . $response->ExtCreateBroadcastResult->tollFreeNumber . "\n"; | |
print "goodRecordCountOnFile :" . $response->ExtCreateBroadcastResult->goodRecordCountOnFile . "\n"; | |
print "badRecordCountonFile :" . $response->ExtCreateBroadcastResult->badRecordCountOnFile . "\n"; | |
print "duplicateRecordCount :" . $response->ExtCreateBroadcastResult->duplicateRecrodCountOnFile . "\n"; | |
print "totalRecordCount :" . $response->ExtCreateBroadcastResult->totalRecordCountOnFile . "\n"; | |
if (!IsNullOrEmptyString($response->ExtCreateBroadcastResult->fileUploadErrors->ExtFileUploadError)) | |
{ | |
foreach ($response->ExtCreateBroadcastResult->fileUploadErrors->ExtFileUploadError as $detail) { | |
print "===================================== \n"; | |
print "Line Number :" . $detail->lineNumber . "\n"; | |
print "errorCode :" . $detail->errorCode . "\n"; | |
print "errorMessage :" . $detail->errorMessage . "\n"; | |
} | |
} | |
function IsNullOrEmptyString($question) { | |
return (!isset($question) || trim($question)===''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment