1. Go to this page and download the library: Download pralhadstha/sms-gateways 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/ */
pralhadstha / sms-gateways example snippets
use Pralhadstha\Sms\SmsGateway;
use Pralhadstha\Sms\SmsMessage;
function notify(SmsGateway $sms): void
{
$result = $sms->send(new SmsMessage(
to: '+9779800000000',
text: 'Your account has been activated.',
));
if ($result->failed()) {
// inspect $result->error and $result->raw
}
}
use GuzzleHttp\Client;
use Nyholm\Psr7\Factory\Psr17Factory;
use Pralhadstha\Sms\Gateway\SparrowGateway;
$factory = new Psr17Factory();
$sms = new SparrowGateway(
client: new Client(),
requestFactory: $factory,
streamFactory: $factory,
token: getenv('SPARROW_TOKEN'),
from: 'YourIdentity',
);
final class MyProviderGateway implements SmsGateway
{
public function send(SmsMessage $message): SmsResult
{
// ... call the provider, map the response ...
return SmsResult::success();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.