-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest.php
38 lines (24 loc) · 887 Bytes
/
latest.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
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
// ERROR REPORTING ON
error_reporting(E_ALL);
ini_set('display_errors', '1');
function getFile($filename){
return file_get_contents($filename);
}
function latestMessage(){
$dataFile = 'latest.json';
// Get each of the latest data file contents.
$citiBikeData = getFile('citibike/' . $dataFile);
$metroData = getFile('metro/' . $dataFile);
$busData = getFile('bus/' . $dataFile);
$weatherData = getFile('weather/' . $dataFile);
$bitcoinData = getFile('bitcoin/' . $dataFile);
// Get other data like current time and day
$now = new DateTime('America/New_York');
$date = $now->format('l, M d Y H:i:s');
$msg = $date . '. ' . $weatherData .' '. $metroData .' '. $busData .' BTC: $' . $bitcoinData . '. Citibikes: ' . $citiBikeData . '.';
return $msg;
}
//header("Content-type:application/json");
echo latestMessage();
?>