PHP code example of dekiakbar / bmkg-api-php-client

1. Go to this page and download the library: Download dekiakbar/bmkg-api-php-client 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/ */

    

dekiakbar / bmkg-api-php-client example snippets



use Dekiakbar\BmkgApiPhpClient\Forecast;
$data = new Forecast();
//this will return data only from  West java province
print_r($data->execute('JawaBarat')->getData());
//this will return data from all provinces
print_r($data->execute()->getData());

//this will retun available area code, you can pass this area code to execute method
//this will return array
print_r($data->getAreaList());

//this will return available city list from West java province
print_r($data->execute('JawaBarat')->getCityList()->getData());

//this will return data only for spesific city
print_r($data->execute('JawaBarat')->getDataByCityId('501212')->getData());
//this will return data for all city, coz there is no parameter passed to the function
print_r($data->execute('JawaBarat')->getDataByCityId()->getData());

//this will return available data id from specific city
print_r($data->execute('JawaBarat')->getDataByCityId('501212')->getDataList()->getData());

//this will return specific data from specific city
print_r($data->execute('JawaBarat')->getDataByCityId('501212')->getDataById('hu')->getData());


use Dekiakbar\BmkgApiPhpClient\Earthquake;

// Earthquake class initialization
$data = new Earthquake();

// This will method will get data from bmkg, then will fetch the data and return as StdClass onject
// if there is no parameter passed to the excute method then it will return defsult data (autogempa)
print_r( $data->execute()->getData() );

// With parameter example
print_r( $data->execute('lasttsunami')->getData() );

// This will return available code list for execute method
print_r( $data->getCodeList() );

PHP >= 5.6
php-xml 

composer