SMSv2 PHP

From CDYNE Wiki
Revision as of 15:12, 13 October 2010 by imported>Wcchenoweth
Jump to navigation Jump to search

The following example was 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.

<php>

// 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);

</php>

AdvancedSMSSend

  • Send different messages to different numbers with one method.

<php>

$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;
 }

}

</php>

GetMessageStatusByReferenceID

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

<php>

$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);

</php>

GetUnreadIncomingMessages

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

<php>

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

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

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

print_r($result);

</php>

GetMessageStatus

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

<php>

$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);

</php>