This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Разрешаем CORS | |
header('Access-Control-Allow-Origin: *'); | |
header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); | |
header('Access-Control-Allow-Headers: Content-Type'); | |
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { | |
header('HTTP/1.1 200 OK'); | |
exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); // Импортируем встроенный модуль crypto | |
const initData = "ваша строка initData"; // замените на реальные данные, которые вы получили | |
// Парсинг initData | |
const params = new URLSearchParams(initData); // Создаем объект URLSearchParams для парсинга строки initData | |
const parsedData = {}; // Создаем пустой объект для хранения разобранных данных | |
// Проходим по всем записям (парам "ключ-значение") в params и добавляем их в parsedData | |
for (const [key, value] of params.entries()) { |