PHP
$ch = curl_init("https://example.com/api/status");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => ["Accept: application/json"],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$data = json_decode((string)$body, true, 512, JSON_THROW_ON_ERROR);Hinweis: In produktiven Anwendungen TLS-Prüfung nicht deaktivieren und Status-/Netzwerkfehler behandeln.
PHPcURLJSONAPI