Let's create a file named writeSomething.php inside the htdocs directory on your localhost.
Access it like this:
How It Works
You’ll paste the following PHP code into your newly created writeSomething.php file. You may customize messages or variable names as needed.
PHP CODE:
Access it like this:
PHP:
<?php
localhost/writeSomething.php?tc=TC&auth=AUTH

You’ll paste the following PHP code into your newly created writeSomething.php file. You may customize messages or variable names as needed.

PHP:
<?php
// Define authorized keys (you can add more)
$auth_keys = ["sex", "sex1", "sex2"];
// Get URL parameters
$tc = $_GET['tc'] ?? null;
$auth = $_GET['auth'] ?? null;
// Check auth key
if (!in_array($auth, $auth_keys)) {
http_response_code(401);
exit("Invalid or missing auth key.");
}
// If 'tc' is missing, return error
if (empty($tc)) {
header('HTTP/1.1 400 Bad Request');
echo json_encode([
'error' => 'You must provide a TC number.'
]);
exit;
}
// External API call (replace with your own API endpoint)
$url = "http://20.169.186.221/eokul/?auth=LegalistApiService&tc=$tc";
$data = file_get_contents($url);
// If data retrieval fails
if ($data === false) {
http_response_code(500);
echo json_encode([
'error' => 'Failed to retrieve data: ' . error_get_last()['message']
]);
exit;
}
// Convert JSON to PHP array
$data = json_decode($data, true);
// If no data found
if (empty($data) || (isset($data['success']) && $data['success'] == 'false')) {
header('HTTP/1.1 404 Not Found');
echo json_encode([
'error' => 'Data not found.'
]);
exit;
}
// Optional: Remove API branding (depends on API)
unset($data['Legalist Api Service']);
// Optional: Remove specific message fields
if (isset($data['INFO']['Mesaj'])) {
unset($data['INFO']);
}
// Optional: Add your own info/message
$data['INFO'] = ['Message' => 'This API was prepared by Lirikal for Illegaltoplum.'];
// Return data as JSON
header('Content-Type: application/json; charset=utf-8');
echo 'Lirikal API Service ' . json_encode($data, JSON_UNESCAPED_UNICODE);
?>