-
Notifications
You must be signed in to change notification settings - Fork 10
/
info.php
35 lines (30 loc) · 1.08 KB
/
info.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
$json = file_get_contents('php://input');
$obj = json_decode($json);
$response=new StdClass();
if($obj){
$uniqueid=isset($obj->uniqueid)?$obj->uniqueid:"uniqueid";
$modelId=isset($obj->modelId)?$obj->modelId*1:0;
$modelName=isset($obj->modelName)?$obj->modelName:"";
$screenWidth=isset($obj->screenWidth)?$obj->screenWidth*1:300;
$screenHeight=isset($obj->screenHeight)?$obj->screenHeight:300;
$data=isset($obj->data)?$obj->data:"";
$battery=isset($obj->battery)?$obj->battery*1:0;
// test data from the phone
$test=isset($obj->test)?$obj->test:false;
$response->status='ok';
$info="";
if($test) $info.="test\n";
else{
$rf=file_get_contents("https://api.coindesk.com/v1/bpi/currentprice.json");
$obj = json_decode($rf);
if($obj && $obj->bpi) $info.="BTC ".round($obj->bpi->USD->rate_float)." USD\n";
}
$info.="\n".gmdate("Y-m-d H:i:s");
$response->info=$info;
$response->vibe=0;
}
else $response->status='error';
header("Content-Type: application/json;charset=utf-8");
echo json_encode($response);
?>