Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
// WhatsApp Cloud API test via Meta
// Replace with your actual values from Meta Developer Portal
$accessToken = 'YOUR_ACCESS_TOKEN_HERE';
$phoneNumberId = 'YOUR_PHONE_NUMBER_ID_HERE';
$recipientPhone = '91XXXXXXXXXX'; // Your verified test number
// WhatsApp API URL
$url = "https://graph.facebook.com/v19.0/{$phoneNumberId}/messages";
// Message body
$data = [
"messaging_product" => "whatsapp",
"to" => $recipientPhone,
"type" => "text",
"text" => [
"body" => "✅ Hello! This is a test message from my POS WhatsApp API using PHP."
]
];
// Convert to JSON
$payload = json_encode($data);
// Set headers
$headers = [
"Authorization: Bearer $accessToken",
"Content-Type: application/json"
];
// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Optional: Only for local testing (disable SSL check - unsafe for production)
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
// Output result
if ($error) {
echo "cURL Error: $error";
} else {
echo "✅ API Response:<br><pre>" . htmlspecialchars($response) . "</pre>";
}
?>
<?php
// WhatsApp Cloud API test via Meta
// Replace with your actual values from Meta Developer Portal
$accessToken = 'EAAeFf2AH3B4BO6fGd6ZA5Gxp9uNkEuStvkAENHwMyKCGyY1bZCbMC8B9cdZAeRh9i18QyDYsNOkmAMZAIFK9zdK9pqgS1jv2qhfLu8IgwXiZBkBbzpXFEzbzwhi4aLJJG34hW3Amy2jZBLDwVvLWAX1K3IdBSPeEaPskJOxfWQIG2u7PpleS7Uhj7hz4PfYojJZAaYDtru8d0Qrj25W2Xy6w6sC91saxrAZBFuhKvpLL40BZAWynm';
$phoneNumberId = '747969295055840';
$recipientPhone = '+9203160005690'; // Your verified test number
// WhatsApp API URL
$url = "https://graph.facebook.com/v19.0/{$phoneNumberId}/messages";
// Message body
$data = [
"messaging_product" => "whatsapp",
"to" => $recipientPhone,
"type" => "text",
"text" => [
"body" => "✅ Hello! This is a test message from my POS WhatsApp API using PHP."
]
];
// Convert to JSON
$payload = json_encode($data);
// Set headers
$headers = [
"Authorization: Bearer $accessToken",
"Content-Type: application/json"
];
// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Optional: Only for local testing (disable SSL check - unsafe for production)
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
// Output result
if ($error) {
echo "cURL Error: $error";
} else {
echo "✅ API Response:<br><pre>" . htmlspecialchars($response) . "</pre>";
}
?>