PHP code example of iankok / surf-forecast-api-client
1. Go to this page and download the library: Download iankok/surf-forecast-api-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/ */
iankok / surf-forecast-api-client example snippets
// Get the 48 hrs forcast for canggu
$client = new SurfForecastClient('http://www.surf-forecast.com/');
$forecastRepository = new ForecastRepository($client, new ForecastMapper());
$forecastRepository->get48HrsAsync('Canggu')->wait();
// Get all available Countries
$countryRepository = new CountryRepository($client, new CountryMapper());
$countryRepository->listAsync()->wait();
// Get all wavebreaks by country id and their forecasts
$waveBreakRepository = new WaveBreakRepositoryAdapter(
new WaveBreakMapper(new Dom()),
new RegionMapper(new Dom()),
$client,
new ResponseInterpreter()
);
$waveBreaks = $waveBreakRepository->getByCountryIdAsync('213')->wait()
$foreCasts = array_map(function ($waveBreak) {
return $forecastRepository->get48HrsAsync($waveBreak->getSlug);
},$waveBreaks
)
all($foreCasts)->wait();
$foreCasts = array_map(function ($waveBreak) {
return $waveBreak->wait();
}, $waveBreaks
)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.