PHP code example of al-saloul / taqnyat

1. Go to this page and download the library: Download al-saloul/taqnyat 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/ */

    

al-saloul / taqnyat example snippets


use Alsaloul\Taqnyat\TaqnyatSms;

$response = TaqnyatSms::sendMessage('Hello, this is a test message.', ['966********'], 'SenderName');
return $response;

use Alsaloul\Taqnyat\TaqnyatSms;

class SmsController extends Controller
{
    protected $sms;

    public function __construct(TaqnyatSms $sms)
    {
        $this->sms = $sms;
    }

    public function sendSms()
    {
        $body = 'Hello, this is a test message.';
        $recipients = ['966********'];
        $sender = 'SenderName';

        $response = $this->sms->sendMessage($body, $recipients, $sender);
        return response()->json($response);
    }
}

TaqnyatSms::sendMessage($body, $recipients, $sender, $smsId = '', $scheduled = '', $deleteId = '');

$response = TaqnyatSms::getBalance();
return $response;

$response = TaqnyatSms::getSenders();
return $response;

$response = TaqnyatSms::getStatus();
return $response;

try {
    $response = TaqnyatSms::sendMessage('Hello, this is a test message.', ['966********'], 'SenderName');
    return $response;
} catch (Exception $e) {
    return 'Error: ' . $e->getMessage();
}
bash
php artisan vendor:publish --provider="Alsaloul\Taqnyat\TaqnyatSmsServiceProvider"