Skip to content

Instantly share code, notes, and snippets.

@Ruekompa
Last active May 22, 2020 15:40
Show Gist options
  • Save Ruekompa/52a11888d9967d69f29b6ad6de61f533 to your computer and use it in GitHub Desktop.
Save Ruekompa/52a11888d9967d69f29b6ad6de61f533 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Hernando County's latest COVID stats</title>
</head>
<body>
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://coronavirus-tracker-api.herokuapp.com/v2/locations/665?source=nyt&timelines=false');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array();
$headers[] = 'Accept: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$json = json_decode($result, true);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $json['location']['latest']['confirmed'];
}
curl_close($ch);
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment