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);
