- file_get_contents: documentation ( source)
- stream_context_create: documentation ( source)
- sha1: documentation ( source)
- date: documentation ( source)
- json_encode: documentation ( source)
<?php
$address = 'https://demo45-pl.yourtechnicaldomain.com/customer-api/?gate=Authenticate/authenticate/7/json';
// SHA1 ile sistem anahtarını oluştur
$hashedKey = sha1(date('Ymd') . sha1('YOUR_KEY'));
$request = array(
"authenticate" => array(
"systemKey" => $hashedKey,
"systemLogin" => "systemLogin"
)
);
// JSON formatına çevir
$request_json = json_encode($request);
// HTTP isteği için header ayarları
$options = array(
'http' => array(
'header' => "Content-Type: application/json\r\n" .
"Accept: application/json\r\n",
'method' => 'POST',
'content' => $request_json,
'ignore_errors' => true // Hata kodlarını da oku
)
);
$context = stream_context_create($options);
$response = file_get_contents($address, false, $context);
if ($response === FALSE) {
die('Hata: Sunucuya bağlanılamadı.');
}
// Sonucu ekrana yazdır
echo "Response:\n";
echo $response;