Joywork/callevents/inssmart.php
2026-05-22 21:21:54 +03:00

41 lines
1.0 KiB
PHP

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
if ($_SESSION['id']) {
$user_id = (int) $_SESSION['id'];
$partnerId = (string)$user_id;
$data = [
"privateKey" => "d3e1e2c5-d2a1-559a-bf98-cedfbb8a9431",
"appGuid" => "3142f191-1e86-5487-9a4a-de0f71b1bb92",
"partnerId" => $partnerId
];
$options = [
'http' => [
'header' => "Content-Type: application/json\r\n" .
"Cache-Control: no cache\r\n",
'method' => 'POST',
'content' => json_encode($data),
'ignore_errors' => true,
]
];
$context = stream_context_create($options);
$url = 'https://api.inssmart.ru/v1/widget/clients/token';
$result = file_get_contents($url, false, $context);
if ($result === false) {
http_response_code(500);
echo json_encode(['error' => 'Request failed']);
exit;
}
header('Content-Type: application/json');
echo $result;
} else {
die('No access');
}