PHP code example of hakanispirli / netgsm-laravel

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

    

hakanispirli / netgsm-laravel example snippets


use HakanIspirli\NetgsmLaravel\Facades\NetgsmSms;

$result = NetgsmSms::send(
    to: '510xxxxxxx',
    message: 'Merhaba, test mesajıdır.',
);

$result = NetgsmSms::sendMany([
    ['to' => '510xxxxxxx', 'message' => 'Birinci mesaj'],
    ['to' => '511xxxxxxx', 'message' => 'İkinci mesaj'],
]);

$result = NetgsmSms::schedule(
    to: '510xxxxxxx',
    message: 'Planlı mesaj',
    startsAt: now()->addDay()->setTime(10, 0),
);

$result = NetgsmSms::otp(
    to: '510xxxxxxx',
    message: 'Your verification code is 1234',
);

NetgsmSms::queueSend([
    ['to' => '510xxxxxxx', 'message' => 'Kuyruk mesajı'],
]);

NetgsmSms::queueOtp(
    to: '510xxxxxxx',
    message: 'Your verification code is 1234',
);

[
    'success' => true,
    'data' => [
        'code' => '00',
        'job_id' => '17377215342605050417149344',
        'description' => 'queued',
        'warning' => null,
        'http_status' => 200,
    ],
]

[
    'success' => false,
    'message' => 'SMS gönderimi tamamlanamadı. Lütfen daha sonra tekrar deneyin.',
    'data' => [
        'code' => '70',
        'job_id' => null,
        'description' => 'Netgsm hata açıklaması',
        'warning' => null,
        'http_status' => 200,
    ],
]
bash
php artisan vendor:publish --tag=netgsm-config
bash
php artisan vendor:publish --tag=netgsm-cron
cron
* * * * * NETGSM_LARAVEL_PROJECT_DIR=/home/USER/public_html PHP_BIN=/usr/local/bin/php /bin/bash /home/USER/public_html/cron/sms.sh >/dev/null 2>&1