File "api-notifiche.inc.php"

Full Path: /srv/www/www.cadoro.it/src/controllers/api-notifiche.inc.php
File size: 678 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') {
    $params = array(
      "c_category_id" => 3,
      "published" => 1,
    );

    $notifications = models\BlogArticle::get($params, 0, 20);

    $result = array(
      "notifications" => array_map(function ($b) { return $b->json(); }, $notifications),
    );

    # 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"));
  }
?>