1. Go to this page and download the library: Download timefrontiers/php-sms 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/ */
use TimeFrontiers\Sms\Result\SendResult;
use TimeFrontiers\Sms\Sms;
$result = Sms::sendResult([
'receiver' => '+234 802 429 6777',
'message' => 'Your verification code is 123456',
'idempotency_key' => 'otp:user-828000000000001:challenge-42',
'idempotency_scope' => 'auth',
]);
switch ($result->outcome) {
case SendResult::ACCEPTED:
case SendResult::REPLAYED:
$sms = $result->sms;
break;
case SendResult::IN_FLIGHT:
// An identical request owns the dispatch claim. Do not send again.
$sms = $result->sms;
break;
case SendResult::UNKNOWN:
// The provider may have accepted it. Do not send again. Reconcile it.
$sms = $result->sms;
break;
default:
$safeErrors = $result->errors;
}
final class MyDriver implements \TimeFrontiers\Sms\Driver\SmsDriverInterface
{
public function send(Sms $sms): ProviderSendResult { /* ... */ }
public function verifyDeliveryReport(WebhookRequest $request): bool { /* ... */ }
public function parseDeliveryReport(WebhookRequest $request): ParsedDeliveryReport { /* ... */ }
public function getProviderName(): string { return 'mydriver'; }
}