SMSv2 PHP

The following examples were built using PHP 5.3.2. Your setup may differ, so please assure that your PHP 5.x version supports the SOAPClient class.

SimpleSMSSend

 * Send a single message to a single number.

// Create a new soap client based on the SMS Notify! WCF service $client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');

// Specify required info to send a text message $param = array(	'PhoneNumber' => '7891234567',	'LicenseKey' => '(your license key here)',	'Message' => 'test' );

// Send the text message $result = $client->SimpleSMSsend($param);

// View the response from CDYNE print_r($result);

SimpleSMSSendWithPostBack
// Create a new soap client based on the SMS Notify! WCF service $client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl'); // Specify required info to send a text message $param = array(	'PhoneNumber' => '5555555555',	'LicenseKey' => '(LicensKey)',	'Message' => 'test',	'StatusPostBackURL' => '(PostBackURL)' ); // Send the text message $result = $client->SimpleSMSsendWithPostback($param); // View the response from CDYNE print_r($result);

AdvancedSMSSend

 * Send SMS messages using cURL

//Request parameters in JSON format $json='{ "LicenseKey":"LicenseKey", "SMSRequests":[{ "AssignedDID":"", "Message":"Hello there", "PhoneNumbers":["PhoneNumber"], "ReferenceID":"", "ScheduledDateTime":"\/Date(1239018869048)\/", "StatusPostBackURL":"" }] }';

//Method $url='http://sms2.cdyne.com/sms.svc/AdvancedSMSsend';

$cURL = curl_init; curl_setopt($cURL,CURLOPT_URL,$url); curl_setopt($cURL,CURLOPT_POST,true); curl_setopt($cURL,CURLOPT_POSTFIELDS,$json); curl_setopt($cURL,CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json')); //If you desire your results in xml format, use the following line for your httpheaders and comment out the httpheaders code line above. //curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $result = curl_exec($cURL); curl_close($cURL);

print_r($result)

AdvancedSMSSend

 * Send SMS messages using SOAP client
 * Send different messages to different numbers with one method.

$client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');

$lk = '(your license key here)';

$PhoneNumbersArray1 = array('0123456789', '4567891230'); $PhoneNumbersArray2 = array('1234567890', '7652212120');

$Message1 = 'Hello World'; $Message2 = 'Goodbye World';

$RequestArray = array(			array( 'AssignedDID'=>'', //If you have a Dedicated Line, you would assign it here. 'Message'=>$Message1, 'PhoneNumbers'=>$PhoneNumbersArray1, 'ReferenceID'=>'', //User defined reference, set a reference and use it with other SMS functions. //'ScheduledDateTime'=>'2010-05-06T16:06:00Z', //This must be a UTC time. Only Necessary if you want the message to send at a later time. 'StatusPostBackURL'=>'' //Your Post Back URL for responses. )			,array( 'AssignedDID'=>'', 'Message'=>$Message2, 'PhoneNumbers'=>$PhoneNumbersArray2, 'ReferenceID'=>'', 'ScheduledDateTime'=>'2010-05-06T16:06:00Z', 'StatusPostBackURL'=>'' )	);

$request = new AdvancedCallRequestData($lk,$RequestArray); //print_r($request);

$result = $client->AdvancedSMSsend($request); print_r($result);

class AdvancedCallRequestData { public $AdvancedRequest;

function AdvancedCallRequestData($licensekey,$requests) { $this->AdvancedRequest = array; $this->AdvancedRequest['LicenseKey'] = $licensekey; $this->AdvancedRequest['SMSRequests'] = $requests; } }

GetMessageStatusByReferenceID

 * Returns all Messages with a predefined user ReferenceID set in AdvancedSMSSend.

$client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');

$param = array(		'ReferenceID' => '(your reference ID, set in AdvancedSMSSend)'		,'LicenseKey' => '(your license key)' );

$result = $client->GetMessageStatusByReferenceID($param);

print_r($result);

GetUnreadIncomingMessages

 * Returns all unread SMSResponses attached to a single License Key and marks them as read.

$client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');

$param = array(		'LicenseKey' => '(your license key)' );

$result = $client->GetUnreadIncomingMessages($param);

print_r($result);

GetMessageStatus

 * Returns the status of a single SMS message using the Message ID from the SMSResponse object.

$client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');

$param = array(		'MessageID' => '(your message ID here)'//MessageID from SMSResponse Object );

$result = $client->GetMessageStatus($param);

print_r($result);