$resource_type = $resource_components[1]; if ($_SERVER['REQUEST_METHOD'] == "GET") { if (count($resource_components) < 2) { header("HTTP/1.1 400 Bad Request"); print "No resource specified."; exit; } if ($resource_type != 'posts' and $resource_type != 'home' and $resource_type != 'songinfo' and $resource_type != 'queue' and $resource_type != 'upload') { header("HTTP/1.1 400 Bad Request"); print "Unknown resource: " . $resource_type; exit; } if (count($resource_components) == 2) { if ($resource_type == 'posts') { $plist = array(); foreach (Songs::getPostList() as $idx => $post) { $plist[] = array('id' => $post['id'], 'title' => $post['title'], 'artist' => $post['artist'], 'artwork_url' => $post['artwork_url']); // print(json_encode($plist)); } header('Content-type: application/json'); print json_encode($plist); exit; } else { if ($resource_type == 'home') { header('HTTP/1.1 200 Success'); print "Success"; exit; } } } if (count($resource_components) == 3) {