Whatsapp API send message PHP
How to Send a Message by WhatsApp API using PHP
Last updated
How to Send a Message by WhatsApp API using PHP
Last updated
Before you begin, ensure that you have installed PHP and the curl extension on your server or local machine.
Sign up and connect any phone number to the channel that appears on the dashboard.
Don't worry, you can disconnect at any time, but it's necessary for WhatsApp automation. To do this, navigate to your personal account where you'll find a QR code for the available channel. Then, open WhatsApp on your mobile device, go to Settings -> Linked devices -> Link a device -> Scan QR code.
Now save the generated API-Key token:
Send your first WhatsApp message ๐
To send a text message, you need to make a request to:
POST https://gate.whapi.cloud/messages/text
'to': The recipientโs WhatsApp number with international format e.g., 14409416972 or chatID for contact or group e.g 14409416972@s.whatsapp.net or 120361234567890@g.us
'body' : Message text.
Save the PHP script and run it on your server. The specified message will be sent to the specified WhatsApp number. Remember to replace variables with your actual details.
Please note that this is a basic example and doesn't include any error handling. For a production environment, ensure to add appropriate error and exception handling. Please don't hesitate to reach out to share your experiences or pose any questions you might have.
Use the source code of ready-made WhatsApp bots as a platform for an easy start. Download, insert your token and launch!
Additional endpoint for easy send media-file as message. Use request body as file and inpath parameters for send parameters. Media message can be one of the following types:
You can Send a ppt audio recording to the phone number or group, But WhatsApp is sensitive to this extension, you need to be in OGG format and the codecs should be the opus. Our API has an automatic video and audio converter for the necessary codecs compatible with WhatsApp. For more information, you can check out this article.