1. Go to this page and download the library: Download renderbit/laravel-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/ */
renderbit / laravel-whatsapp example snippets
use Renderbit\LaravelWhatsapp\WhatsappClient;
class MessageController extends Controller
{
public function send(WhatsappClient $whatsapp)
{
$response = $whatsapp->sendMessage(
'919876543210', // Phone number (no special chars)
'1043144443', // Template ID
['John Doe', '1500'] // Template parameters
);
if ($response['success']) {
return back()->with('success', 'Message sent!');
}
return back()->with('error', $response['message']);
}
}
use Renderbit\LaravelWhatsapp\Facades\Whatsapp;
$response = Whatsapp::sendMessage('919876543210', '1043144443', ['Jane', '2500']);