PHP code example of bahricanli / netgsm

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

    

bahricanli / netgsm example snippets


/*
 * Package Service Providers...
 */

NotificationChannels\Netgsm\NetgsmServiceProvider::class,

'Netgsm' => NotificationChannels\Netgsm\Netgsm::class,

...
    'Netgsm' => [
        'client'     => 'http', // or xml
        'http'       => [
            'endpoint' => 'https://service.jetsms.com.tr/SMS-Web/HttpSmsSend',
        ],
        'xml'        => [
            'endpoint' => 'www.biotekno.biz:8080/SMS-Web/xmlsms',
        ],
        'username'   => '',
        'password'   => '',
        'originator' => "", // Sender name.
        'timeout'    => 60,
    ],
...

use NotificationChannels\Netgsm\NetgsmChannel;
use NotificationChannels\Netgsm\NetgsmMessage;

class ResetPasswordWasRequested extends Notification
{
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [NetgsmChannel::class];
    }
    
    /**
     * Get the Netgsm representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return string|\NotificationChannels\Netgsm\NetgsmMessage
     */
    public function toNetgsm($notifiable) {
        return "Test notification";
        // Or
        return new ShortMessage($notifiable->phone_number, 'Test notification');
    }
}

class User extends Authenticatable
{
    use Notifiable;
    
    public function routeNotificationForNetgsm()
    {
        return "905123456789";
    }
}

Netgsm::sendShortMessage($to, $message);
Netgsm::sendShortMessages([[
    'recipient' => $to,
    'message'   => $message,
], [
    'recipient' => $anotherTo,
    'message'   => $anotherMessage,
]]);

namespace App\Listeners;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use NotificationChannels\Netgsm\Events\MessageWasSent;

class SentMessageHandler
{
    /**
     * Handle the event.
     *
     * @param  MessageWasSent  $event
     * @return void
     */
    public function handle(MessageWasSent $event)
    {
        $response = $event->response;
        $message = $event->message;
    }
}