PHP code example of colesnic89 / smso
1. Go to this page and download the library: Download colesnic89/smso library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
colesnic89 / smso example snippets
use SMSO\ApiClient;
// initialize ApiClient
$apiClient = new ApiClient('your-api-token-here');
// get list senders
$smsSenders = $apiClient->getSenders();
foreach ($smsSenders as $sender) {
echo $sender->getId();
echo $sender->getName();
echo $sender->getPricePerMessage();
}
// send SMS message
$sendMessageResponse = $apiClient->sendMessage('+40123456789', 'Message text', $smsSenders[0]->getId());
echo $sendMessageResponse->getStatus();
echo $sendMessageResponse->getResponseToken();
// check message status
$checkStatusResponse = $apiClient->checkMessageStatus($sendMessageResponse->getResponseToken());
echo $checkStatusResponse->getStatus();
echo $checkStatusResponse->getData()->getStatus();
echo $checkStatusResponse->getData()->getSentAt();
echo $checkStatusResponse->getData()->getDeliveredAt();
echo $checkStatusResponse->getData()->getReceiver()->getNumber();
echo $checkStatusResponse->getData()->getReceiver()->getMcc();
echo $checkStatusResponse->getData()->getReceiver()->getMnc();
// check remaining credit
$checkRemainingCreditResponse = $apiClient->checkRemainingCredit();
echo $checkRemainingCreditResponse->getStatus();
echo $checkRemainingCreditResponse->getCreditValue();