PHP code example of zapply / zapply-laravel

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

    

zapply / zapply-laravel example snippets

   
// config/app.php
'providers' => [
    // ...
    Zapply\Laravel\ZapplyServiceProvider::class,
],

use Zapply\Laravel\Facades\Zapply;

Zapply::chat('552199999999')->sendMessage([
    'recipient_type' => 'individual',
    'type' => 'text',
    'message' => [
        'body' => 'Hello World!',
    ]
])

class User extends Eloquent
{
    use Notifiable;

    public function routeNotificationForZapply()
    {
        return $this->number;
    }
}

use Illuminate\Notifications\Notification;
use Zapply\Laravel\Zapply;
use Zapply\Laravel\Messages\TextMessage;

class InvoicePaid extends Notification
{
    public function via($notifiable)
    {
        return [Zapply::class];
    }

    public function toZapply($notifiable)
    {
        return TextMessage::create('Your invoice has been paid!');
    }
}

use Zapply\Laravel\Messages\TextMessage;
use Zapply\Laravel\Messages\ImageMessage;
use Zapply\Laravel\Messages\AudioMessage;
use Zapply\Laravel\Messages\DocumentMessage;
use Zapply\Laravel\Messages\VideoMessage;

TextMessage::create('Hello World!');

ImageMessage::create('https://example.com/image.jpg', 'Caption!');

AudioMessage::create('https://example.com/audio.mp3');

DocumentMessage::create('https://example.com/document.pdf', 'Caption!');

VideoMessage::create('https://example.com/video.mp4', 'Caption!');

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


 
namespace App\Listeners;
 
use Zapply\Laravel\Events\WebhookReceived;
 
class ZapplyEventListener
{
    /**
     * Handle received Stripe webhooks.
     */
    public function handle(WebhookReceived $event): void
    {
        if ($event->payload['event'] === 'message') {
            // Handle the incoming event...
        }
    }
}