Rate limit of openweathermap.org API Call
This commit is contained in:
@ -1,4 +1,17 @@
|
||||
<?php
|
||||
// Rate limit of 1 request per 2 second
|
||||
session_start();
|
||||
if (isset($_SESSION['LAST_CALL'])) {
|
||||
$last = strtotime($_SESSION['LAST_CALL']);
|
||||
$curr = strtotime(date("Y-m-d h:i:s"));
|
||||
$sec = abs($last - $curr);
|
||||
if ($sec <= 2) {
|
||||
$data = 'Rate Limit Exceeded';
|
||||
echo $data;
|
||||
}
|
||||
}
|
||||
$_SESSION['LAST_CALL'] = date("Y-m-d h:i:s");
|
||||
|
||||
include 'keyVariable.php';
|
||||
ini_set("allow_url_fopen", 1);
|
||||
$cityName = $_COOKIE['city'];
|
||||
|
Reference in New Issue
Block a user