PHP code example of wilsonglasser / laravel-chatapi-whatsapp

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

    

wilsonglasser / laravel-chatapi-whatsapp example snippets


// config/app.php
'providers' => [
    ...
    NotificationChannels\ChatAPI\ChatAPIServiceProvider::class,
],

// config/services.php
...
'chatapi' => [
    'token'          => env('CHATAPI_TOKEN', ''),
    'api_url'       => env('CHATAPI_URL', ''),
],
...

...
/**
 * Route notifications for the Telegram channel.
 *
 * @return int
 */
public function routeNotificationForChatAPI()
{
    return $this->phone;
}
...
 php
use NotificationChannels\ChatAPI\ChatAPIChannel;
use NotificationChannels\ChatAPI\ChatAPIMessage;
use Illuminate\Notifications\Notification;

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

    public function toChatAPI($notifiable)
    {
        return ChatAPIMessage::create()
            ->to($notifiable->phone) // your user phone
            ->file('/path/to/file','My Photo.jpg')
            ->content('Your invoice has been paid');
    }
}