Changing some single response JSON structures (old structures still included)

This commit is contained in:
Timo Ley 2020-09-30 22:03:52 +02:00
parent 4d8223d01c
commit 1b52881fb5

View file

@ -61,9 +61,16 @@ if ($method == "GET") {
$obj->status = 200; $obj->status = 200;
$path = $row["path"]; $path = $row["path"];
$path = str_replace(" ", "%20", $path); $path = str_replace(" ", "%20", $path);
$obj->link = $jmurl . $path; $obj->link = $jmurl . $path;
$obj->user = $row["user"]; $obj->user = $row["user"];
$obj->category = $row["cat"]; $obj->category = $row["cat"];
$meme = new stdClass();
$meme->link = $jmurl . $path;
$meme->user = $row["user"];
$meme->category = $row["cat"];
$obj->meme = $meme;
} }
} }
break; break;
@ -80,9 +87,16 @@ if ($method == "GET") {
$meme = $memes[$random]; $meme = $memes[$random];
if (isset($meme->path)) { if (isset($meme->path)) {
$obj->status = 200; $obj->status = 200;
$obj->link = $jmurl . $meme->path; $obj->link = $jmurl . $meme->path;
$obj->category = $meme->category; $obj->category = $meme->category;
$obj->user = $meme->user; $obj->user = $meme->user;
$img = new stdClass();
$img->link = $jmurl . $meme->path;
$img->category = $meme->category;
$img->user = $meme->user;
$obj->meme = $img;
} }
break; break;
case "/categories": case "/categories":
@ -97,8 +111,14 @@ if ($method == "GET") {
$row = mysqli_fetch_array($res, MYSQLI_ASSOC); $row = mysqli_fetch_array($res, MYSQLI_ASSOC);
if ($row) { if ($row) {
$obj->status = 200; $obj->status = 200;
$obj->id = $row["id"]; $obj->id = $row["id"];
$obj->name = $row["name"]; $obj->name = $row["name"];
$cat = new stdClass();
$cat->id = $row["id"];
$cat->name = $row["name"];
$obj->category = $cat;
} }
} }
break; break;