Anasayfa / PHP & MYSQL / PHP API İle Covid19 Güncel Verileri Çekmek
PHP API İle Covid19 Güncel Verileri Çekmek

PHP API İle Covid19 Güncel Verileri Çekmek

PHP ile güncel COVID19 verileri çekmek istiyorsanız kullanabileceğiniz API.

Farklı ülke çekmek isterseniz TURKEY kısmını ülke adıyla değiştirmeniz gerekiyor.

Widget ya da farklı sayfa olarak sitenize basit bir şekilde entegre edebilirsiniz.

<?php
setlocale(LC_ALL, 'tr_TR.UTF-8');
$url = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/Coronavirus_2019_nCoV_Cases/FeatureServer/1/query?where=UPPER(Country_Region)%20like%20%27%25TURKEY%25%27&outFields=Last_Update,Recovered,Deaths,Confirmed&returnGeometry=false&outSR=4326&f=json";

$client = curl_init($url);
curl_setopt($client,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($client);

$sonuc = json_decode($response);

$dogrulanan = $sonuc->features[0]->attributes->Confirmed;
$olum = $sonuc->features[0]->attributes->Deaths;
$iyilesen = $sonuc->features[0]->attributes->Recovered;

$unix_timestamp = $sonuc->features[0]->attributes->Last_Update;
$son_guncelleme = date("H:i:s", substr($unix_timestamp, 0, 10));

?>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
	</head>
	<body>
		<br><br>
<table id="tablePreview" class="table">
		<thead>
    <tr>
      <th scope="row">Son Güncelleme</th>
      <th>Doğrulanan Vaka Sayısı</th>
      <th>Toplam Ölüm Sayısı</th>
      <th>İyileşen Hasta Sayısı</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><?php echo strftime("%e %B %Y %A, $son_guncelleme", time());?></td>
      <td><?php echo $dogrulanan;?></td>
      <td><?php echo $olum;?></td>
      <td><?php echo $iyilesen;?></td>
    </tr>
   
  </tbody>
</table>
	</body>
</html>

Önizleme :

 

Cevapla

E-posta adresiniz yayınlanmayacak. Required fields are marked *

*