-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api_direct.php
More file actions
36 lines (31 loc) · 930 Bytes
/
test_api_direct.php
File metadata and controls
36 lines (31 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
// Test direct de l'API via HTTP
$url = 'http://localhost/expertise-sinfinity/api/attendance.php';
$postData = [
'action' => 'create',
'employee_id' => '1',
'date' => '2025-01-08',
'check_in_time' => '09:00',
'status' => 'present'
];
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($postData)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo "=== Réponse brute de l'API ===\n";
echo $result;
echo "\n=== Fin de la réponse ===\n";
// Essayer de décoder le JSON
$json = json_decode($result, true);
if ($json === null) {
echo "Erreur JSON: " . json_last_error_msg() . "\n";
echo "Premiers caractères: " . substr($result, 0, 100) . "\n";
} else {
echo "JSON valide: " . print_r($json, true) . "\n";
}
?>