File "api-punti-vendita.inc.php"

Full Path: /srv/www/www.cadoro.it/src/controllers/api-punti-vendita.inc.php
File size: 622 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') {
    $result = array(
      "stores" => array(),
    );

    $params = array();
    $stores = models\Store::get($params);

    foreach ($stores as $store) {
      $result['stores'][] = $store->json();
    }

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