Unofficial library for send SMS messages with China-ASEAN Information Harbor SMS API from applications written with PHP.
Install caih-sms-php with composer by following command:
composer require yusufthedragon/caih-sms-php
or add it manually in your composer.json
file.
Configure package with your token obtained from CAIH.
\YusufTheDragon\CAIH\SMS::setToken('token');
Configure package with your channel key obtained from CAIH.
\YusufTheDragon\CAIH\SMS::setChannelKey('channelKey');
// or chain it with setToken method
\YusufTheDragon\CAIH\SMS::setToken('token')->setChannelKey('channelKey');
Send a single SMS request to specific number.
\YusufTheDragon\CAIH\SMS::send(array $parameters);
Usage example:
$sendSMS = \YusufTheDragon\CAIH\SMS::send([
'toNumber' => '6282147218942',
'message' => 'Test Message',
'requestId' => time()
]);
var_dump($sendSMS);
Check the sending status of SMS message.
\YusufTheDragon\CAIH\SMS::queryStatus(array $parameters);
Usage example:
$checkSMS = \YusufTheDragon\CAIH\SMS::queryStatus([
'messageId' => '1329851774301548544',
'toNumber' => '6282147218942'
]);
var_dump($checkSMS);
Send SMS messages in batches.
\YusufTheDragon\CAIH\SMS::batchSend(array $parameters);
Usage example:
$batchSendSMS = \YusufTheDragon\CAIH\SMS::batchSend([
'requestId' => time(),
'batchToNumber' => [
'6282147218942',
'6282147218943',
'6282147218944'
],
'batchMessage' => [
'Test SMS 1',
'Test SMS 2',
'Test SMS 3'
]
]);
var_dump($batchSendSMS);
Check the sending status of SMS messages in batches.
\YusufTheDragon\CAIH\SMS::batchQueryStatus(array $parameters);
Usage example:
$batchQueryStatus = \YusufTheDragon\CAIH\SMS::batchQueryStatus([
'requestId' => '160595797880071',
'batchToNumber' => [
'6282147218942',
'6282147218943',
'6282147218944'
],
'batchMessageId' => [
'910471603446566431',
'910471603446566432',
'910471603446566433'
]
]);
var_dump($batchQueryStatus);
For any requests, bugs, or comments, please open an issue or submit a pull request.