PHP code example of track-any-device / sms-gateway
1. Go to this page and download the library: Download track-any-device/sms-gateway 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/ */
track-any-device / sms-gateway example snippets
use TrackAnyDevice\SmsGateway\Contracts\SmsGatewayContract;
class NotificationController extends Controller
{
public function __construct(private SmsGatewayContract $sms) {}
public function notify(string $phone): void
{
$this->sms->send($phone, 'Your order has been dispatched.');
}
}
$sent = $sms->send('+447700900000', 'Hello from TAD!');
if (! $sent) {
// false is returned on HTTP error, gateway error, or network exception
// details are logged via Log::error
}
if ($sms->health()) {
// gateway is reachable and reports status: ok
}
use TrackAnyDevice\SmsGateway\Contracts\SmsGatewayContract;
$this->mock(SmsGatewayContract::class)
->shouldReceive('send')
->once()
->with('+447700900000', 'Hello from TAD!')
->andReturn(true);