PHP code example of quickhelper / quicksms

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

    

quickhelper / quicksms example snippets


use QuickSMS\Services\SmsService;
use QuickSMS\Validators\SmsValidator;

$smsService = new SmsService(new SmsValidator());

// Send SMS via Cequens
$result = $smsService->send([
    'phone' => '+2010000000',
    'message' => 'Test message',
    'provider' => 'cequens',
    'type' => 'sms'
]);

// Send OTP via SMS Misr
$result = $smsService->send([
    'phone' => $phone,
    'message' => $otpCode, 
    'type' => 'otp',
    'provider' => 'smsmisr',
    'template' => env('QUICKSMS_SMSMISR_OTP_TEMPLATE') 
]);

use QuickSMS\Services\TwilioService;

$twilioService = new TwilioService();
$result = $twilioService->send([
    'phone' => '+201234567890',
    'message' => 'Hello from Twilio!'
]);

// Response example:
// [
//     'success' => true,
//     'message' => 'Twilio SMS sent successfully',
//     'data' => [
//         'sid' => 'SM1234567890abcdef',
//         'status' => 'queued'
//     ]
// ]

use QuickSMS\Services\TwilioService;

class NotificationController extends Controller
{
    public function __construct(private TwilioService $twilioService)
    {
    }

    public function sendSMS()
    {
        $result = $this->twilioService->send([
            'phone' => '+201234567890',
            'message' => 'Your verification code is: 123456'
        ]);

        if ($result['success']) {
            return response()->json(['message' => 'SMS sent successfully']);
        }

        return response()->json(['error' => $result['message']], 400);
    }
}

[
    'success' => true|false,
    'data' => [...], // Provider response data
    'message' => 'Status message',
    'provider' => 'provider_name'
]
bash
php artisan vendor:publish --provider="QuickSMS\QuickSMSServiceProvider" --tag="config"