File: /var/www/gurumedia_st_usr/data/www/gurumedia.store/frd-api/frdapi-port443.php
<?php
header('Content-Type: application/json');
/**
* ==============================
* Force POST only
* ==============================
*/
if($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode([
'success' => false,
'error' => 'Only POST method allowed',
'allowed' => ['POST']
]);
exit;
}
function receiveData(): array
{
$contentType = $_SERVER['CONTENT_TYPE'] ?? '';
if (stripos($contentType, 'application/json') !== false) {
$raw = file_get_contents('php://input');
$data = json_decode($raw, true);
return is_array($data) ? $data : [];
}
return $_POST;
}
// Usage
$data = receiveData();
/**
* ==============================
* Success Response
* ==============================
*/
echo json_encode([
'success' => true,
'message' => 'Request received successfully',
'debug' => [
'received_data' => $data,
'request_ip' => $_SERVER['REMOTE_ADDR'] ?? null,
'server_ip' => $_SERVER['SERVER_ADDR'] ?? null,
'time' => date('Y-m-d H:i:s')
]
], JSON_PRETTY_PRINT);