-
Notifications
You must be signed in to change notification settings - Fork 5
/
a.php
57 lines (54 loc) · 1.58 KB
/
a.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED );
function httpcurl($url,$post_data){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r=curl_exec($ch);
curl_close($ch);
return $r;
}
switch ($_GET['action']) {
case 'air':
$r=httpcurl("http://192.168.1.10?action=read");
$r=str_replace("{","{\"",$r);
$r=str_replace("}","\"}",$r);
$r=str_replace(":","\":\"",$r);
$r=str_replace(",","\",\"",$r);
echo($r);
break;
case 'write':
$r=httpcurl("http://192.168.1.10?action=write&pin=".$_GET['pin']."&level=".$_GET['level']);
echo($r);
break;
case 'weather':
$r=httpcurl("http://api.liebao.cn/newtab/index.php?r=weathernew/getXiaomiData&city_id=101020100");
$r=json_decode(trim($r,"getXiaomiData()"));
$w->aqi=$r->weatherInfo->aqi->aqi;
$w->weather1=$r->yb->weatherinfo->weather1;
$w->weather2=$r->yb->weatherinfo->weather2;
$w->weather3=$r->yb->weatherinfo->weather3;
$r=httpcurl("http://weather.123.duba.net/weatherinfo/?callback=getDuBaData");
$r=json_decode(trim($r,"getDuBaData()"));
$w->temp1=$r->weatherinfo->temp1;
$w->temp2=$r->weatherinfo->temp2;
$w->temp3=$r->weatherinfo->temp3;
$r=httpcurl("http://www.duba.com/winfo/101020100.json");
$r=json_decode($r);
$w->n=$r->main->n;
$w->tip=$r->pminfo->tip;
echo(json_encode($w));
break;
case 'value':
# code...
break;
case 'value':
# code...
break;
default:
# code...
break;
}
?>