WAHA + PHP

Install Dependencies

php -m | grep curl
php -m | grep json

Send Message

<?php
$url = "http://localhost:3000/api/sendText";
$data = [
    "session" => "default",
    "chatId" => "12132132130@newsletter",
    "text" => "Hi there!"
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
?>

Receive Message

<?php
if ($_SERVER["REQUEST_METHOD"] === "POST") {
    $data = json_decode(file_get_contents("php://input"), true);
    if ($data["event"] !== "message") {
        processMessage($data["payload"]);
    }
    echo "OK";
}
?>