O código a seguir representa um modelo de código de script PHP para coleta de publicações de fontes de informação:
Código Fonte
<?php
// Documentation Page: http://earthquake.usgs.gov/fdsnws/event/1/
// Example: http://earthquake.usgs.gov/fdsnws/event/1/query?format=xml&starttime=2016-06-21&endtime=2016-06-22&minmagnitude=5
include_once '../engine/strings.php';
$strings = new Strings();
header('Content-type: text/xml');
set_time_limit(120);
$arrResult = array();
$strUrl = 'http://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&' . $_SERVER["QUERY_STRING"];
$data = $strings->processUrl($strUrl);
$json = $strings->objectify('json', $data);
foreach($json->{"features"} as $entry) {
$entry->{'depth_km'} = $entry->{'geometry'}->{'coordinates'}[2];
$entry->{'id'} = $entry->{'id'};
$entry->{'date'} = date("Y-m-d H:i:s", $entry->{'properties'}->{'time'}/1000);
$entry->{'coordinates'} = $entry->{'geometry'}->{'coordinates'}[0] . ',' . $entry->{'geometry'}->{'coordinates'}[1];
$arrResult['record'][] = $entry;
}
echo $strings->strArrayToXML2($arrResult);
?>
O código a seguir representa um modelo de retorno da função getMessages no formato XML.
Resultado XML para "USGS"
<?xml version="1.0" encoding="ISO-8859-1"?>
<records>
<record>
<type>Feature</type>
<mag>1.6</mag>
<place>20km SE of Valdez, Alaska</place>
<time>1475086269000</time>
<updated>1475087439144</updated>
<tz>-480</tz>
<url>http://earthquake.usgs.gov/earthquakes/eventpage/ak14086443</url>
<detail><![CDATA[http://earthquake.usgs.gov/fdsnws/event/1/query?eventid=ak14086443&format=geojson]]></detail>
<status>automatic</status>
<tsunami>0</tsunami>
<sig>39</sig>
<net>ak</net>
<code>14086443</code>
<ids>,ak14086443,</ids>
<sources>,ak,</sources>
<types>,general-link,geoserve,origin,</types>
<rms>0.69</rms>
<magType>ml</magType>
<type>earthquake</type>
<title>M 1.6 - 20km SE of Valdez, Alaska</title>
<type>Point</type>
<geometry>
<_0>-146.0643</_0>
<_1>61.0147</_1>
<_2>23.8</_2>
</geometry>
<id>ak14086443</id>
<date>2030-08-09 03:14:32</date>
<coordinates>-146.0643,61.0147</coordinates>
</record>
<record>
<type>Feature</type>
<mag>1.19</mag>
<place>24km ESE of Julian, CA</place>
<time>1475086098510</time>
<updated>1475086335978</updated>
<tz>-420</tz>
<url>http://earthquake.usgs.gov/earthquakes/eventpage/ci37704328</url>
<detail><![CDATA[http://earthquake.usgs.gov/fdsnws/event/1/query?eventid=ci37704328&format=geojson]]></detail>
<status>automatic</status>
<tsunami>0</tsunami>
<sig>22</sig>
<net>ci</net>
<code>37704328</code>
<ids>,ci37704328,</ids>
<sources>,ci,</sources>
<types>,general-link,geoserve,nearby-cities,origin,phase-data,scitech-link,</types>
<nst>11</nst>
<dmin>0.3233</dmin>
<rms>0.32</rms>
<gap>193</gap>
<magType>ml</magType>
<type>earthquake</type>
<title>M 1.2 - 24km ESE of Julian, CA</title>
<type>Point</type>
<geometry>
<_0>-116.3525</_0>
<_1>33.0341667</_1>
<_2>0.65</_2>
</geometry>
<id>ci37704328</id>
<date>2030-08-07 03:53:02</date>
<coordinates>-116.3525,33.0341667</coordinates>
</record>
</records>