-
Notifications
You must be signed in to change notification settings - Fork 0
/
wx-ws.php
35 lines (27 loc) · 960 Bytes
/
wx-ws.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
<?php
//Feature Complete Example of Output
//Needs sanitization of $_POST (week 5)
//Needs output success checking (week 6)
$_POST['zip'] = "54481";
$zip = $_POST['zip'];
require_once("DDCurl.php");
$cc = new DDCurl();
$data = array();
$data["response"]["version"] = 1;
$cc->setURL("http://cwa.braingia.org/ddwi/week4/sourcedata/wx-forecast.php");
$cc->setPostFields("zip=54481");
$cc->getURL();
$forecast = explode("|",$cc->output);
$data["response"][$zip]["dayOne"] = $forecast[0];
$data["response"][$zip]["dayTwo"] = $forecast[1];
$cc->setURL("http://cwa.braingia.org/ddwi/week4/sourcedata/wx-current.php?zip=54481");
$cc->getURL();
$curr = explode("|", $cc->output);
$data["response"][$zip]["temp"] = $curr[0];
$data["response"][$zip]["condition"] = $curr[1];
print json_encode($data);
//Student:
// -Accept input from a caller (choose GET or POST)
// -Gather data from different sources (see examples)
// -Send output to caller in JSON format.
?>