24 lines
583 B
PHP
24 lines
583 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
class MeteoController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$idCity = 2995971;
|
|
$apiKey = config('portal.open_weather_map_api_key');
|
|
$params = '&units=metric&lang=fr';
|
|
$url = 'https://api.openweathermap.org/data/2.5/forecast?id='.$idCity.'&appid='.$apiKey.$params;
|
|
$client = new \GuzzleHttp\Client();
|
|
|
|
$promise = $client->requestAsync('GET', $url);
|
|
$response = $promise->wait();
|
|
|
|
return $response->getBody()->getContents();
|
|
|
|
}
|
|
}
|