Empowering Minds with Tech Knowledge.

How to send message using WhatsApp API?

How to send message using WhatsApp API?

03/February/2025 19:43    Comments (0)     Share:        Bookmark

You can use the below PHP code to send a message using our Whatsapp API.  

$url    = "https://wap-portal.xhost.co.in/api/v1/send.php";
$apikey = "Enter API Key";
$mobile = "Enter mobile number with 91 country code";
$msg    = "Enter message";
$media  = "Enter Image/PDF/Video URL";  //(Optional)

$data = [
    "api_key" => $apikey,
    "number"  => $mobile,
    "message" => $msg
];
if (!empty($media)) {
    $data["media_url"] = $media;
}

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => http_build_query($data),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 30,
    CURLOPT_CONNECTTIMEOUT => 10,
]);

$response = curl_exec($ch);
curl_close($ch);


Comments (0)
Leave a Reply

Your email address and mobile will not be published.

Trending Blog
Related Blog

22/February/2025 16:38 Comments (0)
How to setup OTP SMS API in your code?
03/February/2025 19:43 Comments (0)
How to send message using WhatsApp API?

Subscribe our Newsletter