PHP code example of ges / laravel-green-api

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

    

ges / laravel-green-api example snippets


use Ges\LaravelGreenApi\Services\GreenApiInboxService;

$inbox = app(GreenApiInboxService::class);
$message = $inbox->sendTextMessage($user, 'Hello');
$conversation = $user->greenApiConversation;

use Ges\LaravelGreenApi\Notifications\GreenApiChannel;
use Ges\LaravelGreenApi\Notifications\GreenApiMessage;
use Illuminate\Notifications\Notification;

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

    public function toGreenApi(object $notifiable): GreenApiMessage
    {
        return GreenApiMessage::make('Invoice paid.');
    }
}

public function via(object $notifiable): array
{
    return ['green_api'];
}

public function toGreenApi(object $notifiable): GreenApiMessage
{
    return GreenApiMessage::make()
        ->file(storage_path('app/invoice.pdf'), 'Invoice attached', 'invoice.pdf');
}

use Illuminate\Support\Facades\Notification;

Notification::route('green_api', '+33 6 12 34 56 78')
    ->notify(new InvoicePaid);
bash
composer green-api:install
php artisan migrate
bash
php artisan green-api:check-connection
php artisan green-api:sync-webhook