File "api-preferiti.inc.php"
Full Path: /srv/www/www.cadoro.it/src/controllers/api-preferiti.inc.php
File size: 731 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: text/json; charset="UTF-8"');
# GET
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$favourites = $user->get_favourites();
$favourites = array_values(array_filter($favourites, function ($i) {
return in_array($i['content_type'], array('blog-article'));
}));
$result = array(
"favourites" => array_map(function ($b) { return $b['content']->json(); }, $favourites),
);
# JSON output
echo json_encode($result);
}
# DEFAULT
else {
header('HTTP/1.0 400 Bad Request', true, 400);
header("Content-Type: application/json; charset=utf-8");
echo json_encode(array("error" => "unsupported method"));
}
?>