1. Go to this page and download the library: Download stormgeo/advisorcore library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stormgeo / advisorcore example snippets
use StormGeo\AdvisorCore\AdvisorCore;
$advisor = new AdvisorCore('<your-token>');
use StormGeo\AdvisorCore\Payloads\ClimatologyPayload;
$climatologyPayload = new ClimatologyPayload([
'localeId' => 3477,
'variables' => ['precipitation']
]);
// requesting daily climatology data
$response = $advisor->climatology->getDaily($climatologyPayload);
// requesting monthly climatology data
$response = $advisor->climatology->getMonthly($climatologyPayload);
if (is_null($response->error)) {
print_r($response->data);
} else {
print_r('Error trying to get data!');
print_r($response->error);
}
use StormGeo\AdvisorCore\Payloads\CurrentWeatherPayload;
$payload = new CurrentWeatherPayload([
'localeId' => 3477,
'variables' => ['temperature', 'precipitation']
]);
$response = $advisor->currentWeather->get($payload);
if (is_null($response->error)) {
print_r($response->data);
} else {
print_r('Error trying to get data!');
print_r($response->error);
}
use StormGeo\AdvisorCore\Payloads\WeatherPayload;
$payload = new WeatherPayload([
'localeId' => 3477,
'variables' => ['temperature', 'precipitation']
]);
// requesting daily forecast data
$response = $advisor->forecast->getDaily($payload);
// requesting hourly forecast data
$response = $advisor->forecast->getHourly($payload);
// requesting period forecast data
$response = $advisor->forecast->getPeriod($payload);
if (is_null($response->error)) {
print_r($response->data);
} else {
print_r('Error trying to get data!');
print_r($response->error);
}
$response = $advisor->monitoring->getAlerts();
if (is_null($response->error)) {
print_r($response->data);
} else {
print_r('Error trying to get data!');
print_r($response->error);
}
use StormGeo\AdvisorCore\Payloads\WeatherPayload;
use StormGeo\AdvisorCore\Payloads\GeometryPayload;
use StormGeo\AdvisorCore\Payloads\LightningLitePayload;
use StormGeo\AdvisorCore\Payloads\RadiusPayload;
use StormGeo\AdvisorCore\Payloads\StationPayload;
$payload = new WeatherPayload([
'localeId' => 3477,
'variables' => ['temperature', 'precipitation']
]);
// requesting daily observed data
$response = $advisor->observed->getDaily($payload);
// requesting hourly observed data
$response = $advisor->observed->getHourly($payload);
// requesting period observed data
$response = $advisor->observed->getPeriod($payload);
$stationPayload = new StationPayload([
'stationId' => 'bWV0b3M6MDEyMEM5RkU6LTIzLjkzMDY4NDotNDYuNDg4NTQ4'
]);
// requesting station observed data
$response = $advisor->observed->getStationData($stationPayload);
$radiusPayload = new RadiusPayload([
'localeId' => 3477,
'radius' => 10000
]);
// requesting fire-focus observed data
$response = $advisor->observed->getFireFocus($radiusPayload);
// requesting lightning observed data
$response = $advisor->observed->getLightning($radiusPayload);
// requesting lightning observed details data
$response = $advisor->observed->getLightningDetails($radiusPayload);
$geometryPayload = new GeometryPayload([
'startDate' => '2024-11-28 00:00:00',
'endDate' => '2024-11-28 12:59:59',
'geometry' => '{"type": "MultiPoint", "coordinates": [[-41.88, -22.74]]}'
]);
$lightningLitePayload = new LightningLitePayload([
'startDate' => '2024-11-28 00:00:00',
'endDate' => '2024-11-28 12:59:59',
'geometry' => '{"type": "MultiPoint", "coordinates": [[-41.88, -22.74]]}',
'page' => 1,
'pageSize' => 10
]);
// requesting fire-focus observed data by geometry
$response = $advisor->observed->getFireFocusByGeometry($geometryPayload);
// requesting lightning observed data by geometry
$response = $advisor->observed->getLightningByGeometry($geometryPayload);
// requesting lightning lite observed data by geometry
$response = $advisor->observed->getLightningLite($lightningLitePayload);
if (is_null($response->error)) {
print_r($response->data);
} else {
print_r('Error trying to get data!');
print_r($response->error);
}
use StormGeo\AdvisorCore\Payloads\StationsLastDataPayload;
$payload = new StationsLastDataPayload([
'stationIds' => ['station-id-1', 'station-id-2'], // optional
'variables' => ['temperature', 'precipitation'] // optional
]);
// requesting last data from stations
$response = $advisor->stations->getLastData($payload);
if (is_null($response->error)) {
print_r($response->data);
} else {
print_r('Error trying to get data!');
print_r($response->error);
}
$payload = new PlanInfoPayload([
'timezone' => -3 # default timezone is 0 (UTC)
]);
$payloadForRequestDetails = new RequestDetailsPayload([
'page' => 1,
'pageSize' => 3
]);
$localePayload = new PlanLocalePayload([
'localeId' => 3477,
// You can also set Latitude/Longitude or StationId instead of LocaleId
]);
// requesting plan information
$response = $advisor->plan->getInfo($payload);
// requesting access history
$response = $advisor->plan->getRequestDetails($payloadForRequestDetails);
// requesting plan locale information
$response = $advisor->plan->getLocale($localePayload);
if (is_null($response->error)) {
print_r($response->data);
} else {
print_r('Error trying to get data!');
print_r($response->error);
}
// Arbitrary example on how to define a schema
$schemaPayload = [
'identifier' => 'arbitraryIdentifier',
'arbitraryField1' => [
'type' => 'string',
'r',
'arbitraryField1' => 'some text',
];
// requesting all schemas from token
$response = $advisor->schema->getDefinition();
// requesting to upload a new schema
$response = $advisor->schema->postDefinition($schemaPayload);
// requesting to upload data to parameters from schema
$response = $advisor->schema->postParameters($parametersPayload);
if (is_null($response->error)) {
print_r($response->data);
} else {
print_r('Error trying to get data!');
print_r($response->error);
}