<?php
/**
* Frisay Web API test paneli (yerel geliştirme).
* Kullanım: http://localhost/frisay/tools/api-test.php
* API anahtarını Admin → Ayarlar → Web API bölümünden alın.
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
$baseUrl = 'http://localhost/frisay/api/v1'; // sitenizin linki
$apiKey = 'XXXXXX'; // Admin panelden kopyalayın
$result = '';
function apiRequest($method, $url, $apiKey, $data = null)
{
$ch = curl_init();
$headers = [
'X-API-Key: ' . trim($apiKey),
'Accept: application/json',
];
if ($data !== null) {
$headers[] = 'Content-Type: application/json';
}
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => false,
]);
if ($data !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
}
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
return [
'http_code' => $httpCode,
'curl_error' => $error,
'response' => json_decode($response, true) ?: $response,
];
}
$result = apiRequest('GET', $baseUrl . '/orders?page=0&size=20', $apiKey);
echo '<pre>';
print_r($result);
echo '</pre>';