Merhaba arkadaşlar,
Daha önce aynı kalıp ile json verisi çekebiliyordum ama aynı yöntem GEOJson'da işe yaramadı. Nerede hata yapıyorum acaba? Encode de işe yaramadı...
<?php
echo "<pre>
..................TÜRKİYE VE YAKIN ÇEVRESİNDEKİ SON DEPREMLER....................
.....BÖLGESEL DEPREM-TSUNAMİ İZLEME VE DEĞERLENDİRME MERKEZİ HIZLI ÇÖZÜMLERİ.....
......(YAPAY SARSINTI ANALİZİ YAPILMAMIŞTIR) Son 500 deprem listelenmiştir......
Büyüklük
Tarih Saat Enlem(N) Boylam(E) Derinlik(km) MD ML Mw Yer Çözüm Niteliği
---------- -------- -------- ------- ---------- ------------ -------------- --------------
";
class Deprem {
public $siddet;
public $tarih;
public $saat;
public $enlem;
public $boylam;
public $derinlik;
public $yer;
}
function eng2tr($str)
{
$from_arr=array("ç", "Ç", "ğ", "Ğ", "ı", "İ", "ö", "Ö", "ü", "Ü", "ş", "Ş");
$to_arr=array("c", "C", "ğ", "Ğ", "i", "I", "o", "O", "u", "U", "s", "S");
return strtoupper(str_replace($from_arr, $to_arr, $str));
}
$site = file_get_contents("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.geojson");
$depremler = array();
$data = json_decode ($site,JSON_UNESCAPED_UNICODE);
$i = 0;
foreach ($data as $value) {
$deprem = new Deprem();
$deprem->siddet = $value["mag"];
$bilgiler = explode(" ", $value["time"]);
$deprem->tarih = $bilgiler[0];
$deprem->saat = $bilgiler[1];
$deprem->enlem = $value["coordinates"];
$deprem->boylam = $value["coordinates"];
$deprem->derinlik = $value["coordinates"];
$deprem->yer = $value["place"];
$depremler[$i++] = $deprem;
}
// arsort($depremler);
foreach ($depremler as &$deprem){
echo "".$deprem->tarih." "; // tarih
echo "".$deprem->saat." "; // saat
echo "".$deprem->enlem." "; // enlem
echo "".$deprem->boylam." "; // boylam
echo "".$deprem->derinlik." "; // derinlik
echo "-.- "; // MD
echo "".$deprem->siddet." "; // deprem şiddeti
echo "-.- "; // MW
echo ""; // BOŞLUK
echo "".$deprem->yer." "; // yer
echo " İlksel
"; // BOŞLUK
}
echo "
</pre>";
?>
İnanılmaz fazla hatanız var, sadece url değişip çalışmasını ummuş gibisiniz, yapınızı revize ettim, ancak "time" ile gelen format doğru değil konu açıp birinden yardım istersiniz artık yada kendiniz bulursunuz kolay gelsin
<?php
echo "<pre>
..................TÜRKİYE VE YAKIN ÇEVRESİNDEKİ SON DEPREMLER....................
.....BÖLGESEL DEPREM-TSUNAMİ İZLEME VE DEĞERLENDİRME MERKEZİ HIZLI ÇÖZÜMLERİ.....
......(YAPAY SARSINTI ANALİZİ YAPILMAMIŞTIR) Son 500 deprem listelenmiştir......
Büyüklük
<style>th{min-width:100px;}</style>
<table style='text-align:left;'>
<tr>
<th>Tarih</th>
<th>Saat</th>
<th>Enlem(N)</th>
<th>Boylam(E)</th>
<th>Derinlik(km)</th>
<th>MD</th>
<th>ML</th>
<th>Mw</th>
<th>Yer</th>
<th>Çözüm Niteliği</th>
</tr>
<tr>
<th>------</th>
<th>------</th>
<th>------</th>
<th>------</th>
<th>------</th>
<th>------</th>
<th>------</th>
<th>------</th>
<th>------</th>
<th>------</th>
</tr>
";
class Deprem {
public $siddet;
public $tarih;
public $saat;
public $enlem;
public $boylam;
public $derinlik;
public $yer;
}
function eng2tr($str)
{
$from_arr=array("ç", "Ç", "ğ", "Ğ", "ı", "İ", "ö", "Ö", "ü", "Ü", "ş", "Ş");
$to_arr=array("c", "C", "ğ", "Ğ", "i", "I", "o", "O", "u", "U", "s", "S");
return strtoupper(str_replace($from_arr, $to_arr, $str));
}
$site = file_get_contents("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.geojson");
$depremler = array();
$data = json_decode ($site,JSON_UNESCAPED_UNICODE);
$i = 0;
foreach ($data["features"] as $value) {
$deprem = new Deprem();
$deprem->siddet = $value["properties"]["mag"];
$bilgiler = explode(" ", date("Y/m/d H:i", $value["properties"]["time"]));
$deprem->tarih = $bilgiler[0];
$deprem->saat = $bilgiler[1];
$deprem->enlem = $value["geometry"]["coordinates"][0];
$deprem->boylam = $value["geometry"]["coordinates"][1];
$deprem->derinlik = $value["geometry"]["coordinates"][2];
$deprem->yer = $value["properties"]["place"];
$depremler[$i++] = $deprem;
}
// arsort($depremler);
foreach ($depremler as &$deprem){
echo "<tr>"; // tarih
echo "<td>".$deprem->tarih."</td>"; // tarih
echo "<td>".$deprem->saat."</td>"; // saat
echo "<td>".$deprem->enlem."</td>"; // enlem
echo "<td>".$deprem->boylam."</td>"; // boylam
echo "<td>".$deprem->derinlik."</td>"; // derinlik
echo "<td>-.-</td>"; // MD
echo "<td>".$deprem->siddet."</td>"; // deprem şiddeti
echo "<td>-.-</td>"; // MW
echo "<td>".$deprem->yer."</td>"; // yer
echo "<td>İlksel</td>";
echo "</tr>";
}
echo "</table></pre>";
?>