PHP code example of renzojohnson / whatsapp-cloud-api
1. Go to this page and download the library: Download renzojohnson/whatsapp-cloud-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/ */
renzojohnson / whatsapp-cloud-api example snippets
use RenzoJohnson\WhatsApp\WhatsApp;
$wa = new WhatsApp('YOUR_PHONE_NUMBER_ID', 'YOUR_ACCESS_TOKEN');
// Send a text message
$wa->sendText('14155551234', 'Hello from PHP!');
$wa->sendText('14155551234', 'Hello World');
// With link preview
$wa->sendText('14155551234', 'Check https://example.com', previewUrl: true);
// By URL
$wa->sendImage('14155551234', link: 'https://example.com/photo.jpg', caption: 'A photo');
// By media ID (uploaded via uploadMedia)
$wa->sendImage('14155551234', mediaId: 'media_123');