24 lines
577 B
PHP
24 lines
577 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
class MeteoController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$idCity = 2995971;
|
|
$apiKey = env('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();
|
|
|
|
}
|
|
}
|