Skip to content

Instantly share code, notes, and snippets.

@daniel-dona
Created January 30, 2020 22:47
Show Gist options
  • Save daniel-dona/56c9f00a7377e1807d0642bc9597a5f3 to your computer and use it in GitHub Desktop.
Save daniel-dona/56c9f00a7377e1807d0642bc9597a5f3 to your computer and use it in GitHub Desktop.
<?php
//Data from Johns Hopkins CSSE
$q = '[{"statisticType":"sum","onStatisticField":"Confirmed","outStatisticFieldName":"confirmed"}, {"statisticType":"sum","onStatisticField":"Deaths","outStatisticFieldName":"dead"}, {"statisticType":"sum","onStatisticField":"Recovered","outStatisticFieldName":"recovered"}]';
$endpoint = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/".
"ncov_cases/FeatureServer/1/query?f=json&where=1%3D1&returnGeometry=false".
"&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=";
$json = json_decode(file_get_contents($endpoint.urlencode($q)), true);
$data = array();
$data["confirmed"] = $json["features"][0]["attributes"]["confirmed"];
$data["recovered"] = $json["features"][0]["attributes"]["recovered"];
$data["dead"] = $json["features"][0]["attributes"]["dead"];
$output = json_encode($data);
echo $output;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment