false, "message" => translate('session_expired', $i18n) ])); } if ($_SERVER["REQUEST_METHOD"] === "POST") { $postData = file_get_contents("php://input"); $data = json_decode($postData, true); if ( !isset($data["bottoken"]) || $data["bottoken"] == "" || !isset($data["chatid"]) || $data["chatid"] == "" ) { $response = [ "success" => false, "message" => translate('fill_mandatory_fields', $i18n) ]; echo json_encode($response); } else { // Set the message parameters $title = translate('wallos_notification', $i18n); $message = translate('test_notification', $i18n); $botToken = $data["bottoken"]; $chatId = $data["chatid"]; $ch = curl_init(); // Set the URL and other options curl_setopt($ch, CURLOPT_URL, "https://api.telegram.org/bot" . $botToken . "/sendMessage"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'chat_id' => $chatId, 'text' => $message, ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the request $response = curl_exec($ch); // Close the cURL session curl_close($ch); // Check if the message was sent successfully if ($response === false) { die(json_encode([ "success" => false, "message" => translate('notification_failed', $i18n) ])); } else { die(json_encode([ "success" => true, "message" => translate('notification_sent_successfuly', $i18n) ])); } } } else { die(json_encode([ "success" => false, "message" => translate("invalid_request_method", $i18n) ])); } ?>