<?php

$id = $_POST['id'] ?? null;

if (!$id) {
    echo json_encode([
        "success" => false,
        "nickname" => null
    ]);
    exit;
}

$url = "https://api.gifan.id/trueID/freeFire/".$id;

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 10,
]);

$response = curl_exec($ch);

curl_close($ch);

if($response != NULL) {
    echo json_encode([
        "success" => true,
        "nickname" => $response
    ]);
}else{
    echo json_encode([
        "success" => true,
        "nickname" => " "
    ]);
}