fahrigunadi / whatsapp
This is my package whatsapp
Fund package maintenance!
Fahri Gunadi
Installs: 67
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 1
pkg:composer/fahrigunadi/whatsapp
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- spatie/laravel-ray: ^1.35
README
Installation
You can install the package via composer:
composer require fahrigunadi/whatsapp
You can publish the config file with:
php artisan vendor:publish --tag="whatsapp-config"
This is the contents of the published config file:
return [ /** * -------------------------------------------------------------------------- * WhatsApp Driver * -------------------------------------------------------------------------- * * This option defines which driver implementation to use for sending * WhatsApp messages. You may configure your own custom driver or use * one of the available drivers such as 'aldinokemal', 'wuzapi', etc. * * Supported: "aldinokemal", "wuzapi" */ 'driver' => env('WHATSAPP_DRIVER', 'aldinokemal'), /** * -------------------------------------------------------------------------- * WhatsApp Username * -------------------------------------------------------------------------- * * The username used to authenticate with the selected WhatsApp provider. * This value is typically provided by the API service you are integrating with. */ 'username' => env('WHATSAPP_USERNAME'), /** * -------------------------------------------------------------------------- * WhatsApp Password or Token * -------------------------------------------------------------------------- * * The password or access token required to authenticate with the provider. * This credential should be kept secure and never exposed publicly. */ 'password' => env('WHATSAPP_PASSWORD'), /** * -------------------------------------------------------------------------- * WhatsApp Base URL * -------------------------------------------------------------------------- * * The base endpoint URL for the WhatsApp API. This is where all requests * will be sent. Make sure the URL is correct and includes the necessary * protocol (http or https). */ 'base_url' => env('WHATSAPP_BASE_URL'), ];
Usage
whatsapp() ->to('+628XXXXXXXXXX') ->message('Hello World') ->send(); whatsapp() ->to('+628XXXXXXXXXX') ->image('https://files.f-g.my.id/images/dummy/botol-2.jpg') ->send(); \FahriGunadi\Whatsapp\Whatsapp::to('+628XXXXXXXXXX') ->image('https://files.f-g.my.id/images/dummy/botol-2.jpg') ->message('Image Caption') ->send(); // handle webhook in controller public function webhook(\FahriGunadi\Whatsapp\WebhookRequest $request) { // get webhook sender $sender = $request->sender(); // get webhook message text $text = $request->messageText(); // get webhook chat room $room = $request->chat(); // reply webhook message $request->reply()->message("Hello $sender, you said: $text")->send(); // .... }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.