-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
25 lines (21 loc) · 827 Bytes
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
// LLave de la API ver https://developer.accuweather.com/user/me/apps
$apiKey = "14e4bd2eb6c78d28ec031536b968b0f9";
// ID de la ciudad
$cityId = "3667983";
// Llamada a la API
$googleApiUrl = "http://api.openweathermap.org/data/2.5/weather?id=" . $cityId . "&lang=es&units=metric&APPID=" . $apiKey;
//Obtener .json
//http://api.openweathermap.org/data/2.5/weather?id=3667983&lang=es&units=metric&APPID=14e4bd2eb6c78d28ec031536b968b0f9
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $googleApiUrl);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response);
$currentTime = time();
?>