-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlineadd.php
More file actions
36 lines (27 loc) · 735 Bytes
/
Copy pathlineadd.php
File metadata and controls
36 lines (27 loc) · 735 Bytes
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
<?php
header("Access-Control-Allow-Origin: *");
require "../../include/redis/setup.php";
//error_reporting(E_ALL);
//echo $_SERVER['REQUEST_METHOD'];
//ini_set("allow_url_fopen", true);
class Entry{
public $line = "";
public $time = "";
public $user = "";
}
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
//using $_REQUEST as work around since $_POST
//keeps coming up empty
$line = $_REQUEST["line"];
$user = "";
$time = date("Y-m-d H:i:s");
$entry = new Entry;
$entry->time = $time;
$entry->line = $line;
$entry->user = $user;
$store = json_encode($entry);
$room = $_REQUEST["room"];
$redis_client->rpush($room, $store);
echo json_encode($redis_client->lrange($room, 0, -1));
?>