Official PHP client for the ClickSend API — send and manage SMS, MMS, email, voice, fax, letters, postcards, and more.
PHP 8.1 and later.
Via Composer:
composer require clicksend/clicksend-php<?php
require_once(__DIR__ . '/vendor/autoload.php');
$config = ClickSend\Configuration::getDefaultConfiguration()
->setUsername(getenv('CLICKSEND_USERNAME'))
->setPassword(getenv('CLICKSEND_API_KEY'));
$apiInstance = new ClickSend\Api\SmsApi(new GuzzleHttp\Client(), $config);
$sendSmsRequest = new ClickSend\Model\SendSmsRequest([
'messages' => [
['source' => 'sdk', 'body' => 'Hello from ClickSend!', 'to' => '+61411111111'],
],
]);
try {
$result = $apiInstance->sendSms(null, $sendSmsRequest);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SmsApi->sendSms: ', $e->getMessage(), PHP_EOL;
}$managementApi = new ClickSend\Api\ManagementApi(new GuzzleHttp\Client(), $config);
try {
$account = $managementApi->viewAccountDetails();
print_r($account);
} catch (Exception $e) {
echo 'Exception when calling ManagementApi->viewAccountDetails: ', $e->getMessage(), PHP_EOL;
}$mmsApi = new ClickSend\Api\MmsApi(new GuzzleHttp\Client(), $config);
$sendMmsRequest = new ClickSend\Model\SendMmsRequest([
'media_file' => 'https://clicksend.com/logo.png',
'messages' => [
['to' => '+61411111111', 'from' => 'sdk', 'subject' => 'Hello', 'body' => 'Hello from ClickSend!', 'source' => 'sdk'],
],
]);
try {
$result = $mmsApi->sendMms(null, $sendMmsRequest);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling MmsApi->sendMms: ', $e->getMessage(), PHP_EOL;
}The API uses HTTP Basic authentication — your ClickSend username and API key (available from the ClickSend Dashboard).
Full API reference: https://developers.clicksend.com/docs/rest/v3/
Need help? Contact ClickSend Support or visit the Help Centre.