The SaralSMS SDK for PHP makes it easy for developers to access SaralSMS API service in their PHP code, and build robust SMS based applications and software.
- Sign up for SaralSMS – Before you begin, you need to sign up for an SaralSMS account and retrieve your Credentials.
- Minimum requirements – To run the SDK, your system will need to meet the minimum requirements, including having PHP >= 7.2. We highly recommend having it compiled with the cURL extension and cURL compiled with a TLS backend (e.g., NSS or OpenSSL).
Install the SDK – Using Composer is the recommended way to install the SaralSMS SDK for PHP. The SDK is available via Packagist under the saralsms/sdk-for-php
package.
composer require saralsms/sdk-for-php
We use the GitHub issues for tracking bugs and feature requests and address them as quickly as possible.
- Call/Email SaralSMS Support or open ticket in your dashboard.
- If it turns out that you may have found a bug, please open an issue.
// require the composer autoloader.
require 'vendor/autoload.php';
use SaralSMS\Client;
// instantiate a SaralSMS client.
$client = new Client('f9c6......55c1');
This will send the message to one or multiple numbers in an array.
$client->send(['9851xxx123', '9801xxx456'], 'This is test message from API.');
Sample Response
{
"message": "2 messages queued for delivery."
}
This will return the available credits and total messages sent.
$client->getCredits();
Sample Response
{
"credits": 6584,
"total_sent": 3416
}
This will return historical messages reports including networks, charges and status.
$pageNumber = 1;
$client->getReports($pageNumber);
Sample Response
{
"pages": 126,
"data": [
{
"id": 56480058,
"receiver": "9779851xxx123",
"network": "ntc",
"message": "Fruits are an excellent source of essential vitamins and minerals.",
"api_credit": "1",
"delivery_at": "2020-07-09 01:45:09"
},
{
"id": 56480057,
"receiver": "9779801xxx456",
"network": "ncell",
"message": "Vegetables are important sources of many nutrients, including potassium, dietary fiber.",
"api_credit": "1",
"delivery_at": "2020-07-08 07:25:31"
}
]
}