Files
portal/app/Http/Controllers/MeteoController.php
2020-08-10 08:19:29 +02:00

23 lines
582 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();
}
}