Skip to content

Sending WhatsApp Message Using PHP for MerciGlobal Cloud ERP

Overview

This guide provides a simple and effective method to send WhatsApp messages programmatically using PHP. It is particularly useful for developers looking to integrate WhatsApp messaging into MerciGlobal Cloud ERP for sending automated notifications like invoices, alerts, or reminders.


Prerequisites

Before implementing the integration, ensure the following:

  • A registered account with a WhatsApp messaging API provider (e.g., whatapi.in)
  • A valid WEBHOOK ID
  • PHP environment is correctly configured on your server
  • The server is internet-enabled

PHP Code to Send WhatsApp Message

Insert the following PHP snippet into your script:

<?php
class wbot {
    public function send($url) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;
    }
}

$mobile = '91xxxxxxxxxx';
$message = urlencode("Hello, this is an automated message from MerciGlobal Cloud ERP.");
$webhook = "{WEBHOOKID}";

$url = "https://whatapi.in/api/{WEBHOOKID}/send?mobile=$mobile&message=$message";

$bot = new wbot();
echo $bot->send($url);
?>

Replace Placeholders

Placeholder Replace With
91xxxxxxxxxx Your recipient's mobile number
{WEBHOOKID} Your unique webhook ID from the API

Important Notes

  • Use urlencode() to prevent formatting issues in the message.
  • Ensure your wbot class includes a send() method for HTTP GET requests.
  • This method can be integrated into MerciGlobal Cloud ERP to automate WhatsApp alerts.

Security Tip

Avoid hardcoding credentials like webhook IDs in the script. Store them securely using:

  • Environment variables
  • Secured configuration files

Support

Need help integrating this feature into MerciGlobal Cloud ERP?


Happy Messaging 🚀 — MerciGlobal ERP Team