Bearer Token • Dinamik Form • Sipariş API
Örnek Kodlar
cURL ve PHP cURL entegrasyon örnekleri.
curl -X POST "https://api.penceresistemleribayikanali.com/api/Auth/Token" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-API-Request: true" \
-d '{
"entegrasyon_referans_kodu": "PSREF-ABCDEF1234567890ABCD",
"api_key": "PSB_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"api_secret": "PSS_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}'
curl -X GET "https://api.penceresistemleribayikanali.com/api/Urun?lang=tr" \ -H "Accept: application/json" \ -H "X-API-Request: true" \ -H "Authorization: Bearer TOKEN_BURAYA"
<?php
$apiBase = 'https://api.penceresistemleribayikanali.com/api';
function apiRequest(string $method, string $url, array $headers = [], ?array $body = null): array
{
$ch = curl_init();
$finalHeaders = array_merge([
'Accept: application/json',
'X-API-Request: true',
], $headers);
if ($body !== null) {
$finalHeaders[] = 'Content-Type: application/json';
}
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $finalHeaders,
CURLOPT_TIMEOUT => 20,
]);
if ($body !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body, JSON_UNESCAPED_UNICODE));
}
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
return [
'status' => $status,
'error' => $error,
'json' => json_decode((string)$response, true),
'raw' => $response,
];
}
$tokenResponse = apiRequest('POST', $apiBase . '/Auth/Token', [], [
'entegrasyon_referans_kodu' => 'PSREF-ABCDEF1234567890ABCD',
'api_key' => 'PSB_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'api_secret' => 'PSS_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
]);
$token = $tokenResponse['json']['data']['access_token'] ?? null;
if (!$token) {
exit('Token alınamadı');
}
$urunler = apiRequest('GET', $apiBase . '/Urun?lang=tr', [
'Authorization: Bearer ' . $token,
]);
$formSema = apiRequest('GET', $apiBase . '/Urun/FormSema?urun_id=1&lang=tr', [
'Authorization: Bearer ' . $token,
]);
$hesap = apiRequest('POST', $apiBase . '/Siparis/Hesapla', [
'Authorization: Bearer ' . $token,
], [
'urun_id' => 1,
'urun_tip' => 2,
'adet' => 1,
'en' => 100,
'boy' => 120,
'ral_renk' => '7016',
]);
$havuz = apiRequest('POST', $apiBase . '/Siparis/Olustur', [
'Authorization: Bearer ' . $token,
], [
'urun_id' => 1,
'urun_tip' => 2,
'adet' => 1,
'musteri_adi' => 'Test Müşteri',
'en' => 100,
'boy' => 120,
'ral_renk' => '7016',
'fatura_turu' => 1,
'siparis_paket_durum' => 1,
]);
$havuzListe = apiRequest('GET', $apiBase . '/Siparis/Havuz/Liste?page=1&limit=25&havuz_durum=1', [
'Authorization: Bearer ' . $token,
]);
print_r($urunler);
print_r($formSema);
print_r($hesap);
print_r($havuz);
print_r($havuzListe);