Sendmode
Simple PHP library to help leverage the Sendmode API. Sendmode are a 100% Irish owned, multi-award winning Bulk Text provider., (*1)
The Sendmode library features the following functionality
- Send SMS (with/without schedule)
- Send Batch SMS (with/without schedule)
- Get Balance
- Get Delivery Report, (*2)
Please visit Sendmode for more details of their services., (*3)
Installation
Manual Install
Include the lib/sendmode.php file in your project., (*4)
or, (*5)
Automatic Install via Composer
composer require kreative/sendmode, (*6)
Quick Start
Sending a SMS via the Sendmode API is as simple as, (*7)
// Instantiate the class
$sms = new Sendmode($username, $password, $senderid);
// Send SMS
$result = $sms->send($phonenumber, $message);
// API response is returned as a SimpleXML object in $result.
Usage
Instantiation
Class Instantiation requires a Sendmode username, password, Sender ID with an optional return format., (*8)
$username=''; // Your Sendmode Username.
$password=''; // Your Sendmode Password.
$senderid=''; // Sender ID SMS that is displayed to recipients.
$format='json|array'; // Optional return format. Default is SimpleXML object.
// Instantiate the class
$sms = new Sendmode($username, $password, $senderid, $format);
Sending a SMS immediately via the send() method.
The Customer ID is an optional argument., (*9)
// Instantiate the class
$sms = new Sendmode($username, $password, $senderid);
// Send a single SMS
$phonenumber=''; // Phone number in the correct format.
$message=''; // Message to send.
$customerid=''; // Optional message UID used to track delivery reports.
$result = $sms->send($phonenumber, $message, $customerid);
// API response is returned as a SimpleXML object in $result.
Send a single SMS at a scheduled time
Sending a SMS at a scheduled time of your choosing via the send() method. The Customer ID is an optional argument. Both the date & time arguments are required., (*10)
// Instantiate the class
$sms = new Sendmode($username, $password, $senderid);
// Send Scheduled SMS
$phonenumber=''; // Phone number in the correct format.
$message=''; // Message to send.
$customerid=''; // Optional message UID used to track delivery reports.
$date=''; // in d/m/Y e.g. Feb 1st 2016 = 01/02/2016.
$time=''; // in H:i e.g. 1:15PM = 13:15.
$result = $sms->send($phonenumber, $message, $customerid, $date, $time);
// API response is returned as a SimpleXML object in $result.
Sending a SMS immediately via the sendbatch() method.
Phone numbers should be an array of correctly formatted numbers., (*11)
// Instantiate the class
$sms = new Sendmode($username, $password, $senderid);
// Send Scheduled SMS
$phonenumbers=array(); // Array of Phone numbers in the correct format.
$message=''; // Message to send.
$result = $sms->sendbatch($phonenumber, $message);
// API response is returned as a SimpleXML object in $result.
Send SMS to multiple recipients at a scheduled time
Sending a SMS to multiple recipients at a scheduled time of your choosing via the sendbatch() method. Phone numbers should be an array of correctly formatted numbers. In order to schedule the delivery both the date & time arguments are required., (*12)
// Instantiate the class
$sms = new Sendmode($username, $password, $senderid);
// Send Scheduled SMS to multiple recipients.
$phonenumbers=array(); // Array of Phone numbers in the correct format.
$message=''; // Message to send.
$date=''; // in d/m/Y e.g. Feb 1st 2016 = 01/02/2016.
$time=''; // in H:i e.g. 1:15PM = 13:15.
$result = $sms->sendbatch($phonenumber, $message, $customerid, $date, $time);
// API response is returned as a SimpleXML object in $result.
Retrieving a delivery report
You can retrieve the delivery status of a SMS via the getdeliveryreport() method using the UID (customerID) defined at the time of sending the SMS., (*13)
// Instantiate the class
$sms = new Sendmode($username, $password, $senderid);
$customerid=''; // Your UID Customer ID used in the original send request.
$result = $sms->getdeliveryreport($customerid);
// API response is returned as a SimpleXML object in $result.
Retrieving your account balance
Your account balance (SMS credits) can be retrieved via the getbalance() method., (*14)
// Instantiate the class
$sms = new Sendmode($username, $password, $senderid);
$result = $sms->getbalance();
// API response is returned as a SimpleXML object in $result.
License
Licensed under GPL v.3 (tldr), (*15)