Automate WhatsApp Group Document Sharing with PHP
Need to integrate WhatsApp group PDF sharing into your PHP applications for report distribution, automated documentation delivery, or website file sharing? This guide shows you how to deliver PDF files to WhatsApp groups using PHP and the WhatsMate WA Gateway REST API. Perfect for PHP developers building websites, web applications, or any PHP-based system that needs document delivery to group chats.
📋 Prerequisites
Before you begin, ensure you have:
- A WhatsMate WA Gateway Forever Green account - Required for group messaging API access
- Group setup - Create a WhatsApp group with a unique name and add the gateway
- PHP installed - Version 7.0 or higher with cURL extension enabled
- Web server - Apache, Nginx, or any server that can execute PHP
- PDF file ready - Have the document you want to send available on your server
⚠️ Important: You need a Forever Green account to send messages to WhatsApp groups. The gateway must be added to your WhatsApp group before it can send messages. Sign up for a Forever Green account to enable group messaging capabilities.
📄 Document Requirements: The script supports PDF files and other document types (MP4, WAV, etc.). Ensure your file is accessible and not corrupted before sending.
📝 Step-by-Step Implementation
Follow these steps to send your first PDF document to a WhatsApp group from a PHP application:
1. Prepare Your WhatsApp Group
Before coding, set up your WhatsApp group:
- Create a new group in WhatsApp with a unique name (the API won’t work if the name isn’t unique)
- Add the secret gateway number to the group
- Send a “Hi” message (or any message) in the group from your personal WhatsApp account - this helps the gateway silently recognize the new group in the background
2. Copy the PHP Source Code
Start by copying the following source code into your PHP script:
3. Configure Key Parameters
Customize these essential parameters in the PHP script:
- Lines 2-4: Replace
YOUR_INSTANCE_ID_HERE,YOUR_CLIENT_ID_HERE, andYOUR_CLIENT_SECRET_HEREwith your Forever Green credentials - Line 6: Replace
/tmp/your_doc.pdfwith the path to your PDF file on the server - Line 9: Replace
anyname.pdfwith the desired filename for the document - Line 10: Replace
"You will find the map handy."with an optional caption for your PDF - Line 13: Specify your group name (must be unique)
4. Upload and Execute
- Save the PHP file to your web server (e.g.,
send-pdf-group.php) - Ensure the PDF file is accessible at the path specified in line 6 and that PHP has read permissions
- Visit the PHP page in your browser or execute via command line to send your PDF
To execute via command line:
php send-pdf-group.php
To execute via web browser:
Simply navigate to http://your-domain.com/send-pdf-group.php
🔧 Common Use Cases
This PHP integration is ideal for:
- Website document distribution - Allow users to download PDFs that get shared to WhatsApp groups automatically
- E-commerce order confirmations - Automatically send invoices or receipts to customer WhatsApp groups
- Content management systems - Integrate with WordPress, Joomla, or Drupal to share documents to groups
- Web application reporting - Generate and deliver PDF reports from PHP web apps to team WhatsApp groups
- Automated documentation delivery - Send system logs or documentation as PDFs to admin groups
🚀 Get Started Today
Ready to integrate WhatsApp group PDF sharing into your PHP applications? You’ll need a Forever Green account to access the group messaging API. Sign up for a Forever Green account and start sending PDF documents to groups within minutes!
Next Steps: Once you’ve mastered group PDF sending, explore advanced features like sending images to groups or individual messages through the WhatsMate WA Gateway API documentation.