PHP code example of ankurk91 / laravel-vonage-inbound-sms

1. Go to this page and download the library: Download ankurk91/laravel-vonage-inbound-sms 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/ */

    

ankurk91 / laravel-vonage-inbound-sms example snippets


protected $except = [
    '/webhooks/*',
];



namespace App\Jobs\Webhook\Vonage\SMS\Inbound;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\SerializesModels;
use Spatie\WebhookClient\Models\WebhookCall;

class TextSMSJob implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    public function __construct(protected WebhookCall $webhookCall)
    {
        //
    }

    public function handle()
    {      
        $message = new \Vonage\SMS\Webhook\InboundSMS($this->webhookCall->payload);
            
        // todo do something with $message        
    }
}



return [
     'jobs' => [
          'text' => \App\Jobs\Webhook\Vonage\SMS\Inbound\TextSMSJob::class,
     ],
];

protected $listen = [
    'vonage-inbound-sms::unicode' => [
        \App\Listeners\Vonage\SMS\Inbound\UnicodeSMSListener::class,
    ],
];



namespace App\Listeners\Vonage\SMS\Inbound;

use Illuminate\Contracts\Queue\ShouldQueue;
use Spatie\WebhookClient\Models\WebhookCall;

class UnicodeSMSListener implements ShouldQueue
{
    public function handle(WebhookCall $webhookCall)
    {
        $message = $webhookCall->payload;
               
        // todo do something with $message        
    }
}

use Illuminate\Database\Console\PruneCommand;
use Spatie\WebhookClient\Models\WebhookCall;

$schedule->command(PruneCommand::class, [
            '--model' => [WebhookCall::class]
        ])
        ->onOneServer()
        ->daily()
        ->description('Prune webhook_calls.');
bash
php artisan vendor:publish --provider="Ankurk91\Vonage\SMS\Inbound\VonageWebhooksServiceProvider"
bash
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations"
bash
php artisan migrate
bash
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-config"