<?
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Allow: GET, POST, OPTIONS, PUT, DELETE");
$method = $_SERVER['REQUEST_METHOD'];
if($method == "OPTIONS") {
    die();
} ?>

{
	"nota":

  <?
    include 'url_amigable.php';
    include 'concha.php';
    $id_nota = urls_amigables($_GET['nota']);
    mysql_connect ("$host2", "$usuario2", "$contra2");
    mysql_select_db ("$basedatos2");

    $sql = "SELECT * FROM `notas` WHERE `ID` LIKE '$id_nota' LIMIT 1";
    $consulta = mysql_query ($sql);
    while ($row = mysql_fetch_array($consulta))
    {
      $ID = $row["ID"];
      $titulo = $row["titulo"];
      $bajada = $row["bajada"];
      $texto = $row["texto"];
      $foto = $row["foto"];
      $carpetafoto = $row["carpetafoto"];
      $ext_img = $row["ext_img"];
      $youtube = $row["youtube"];
      $titulo = str_replace('"',"'", $titulo);
      $bajada = str_replace('"',"'", $bajada);
      $texto = str_replace('"',"'", $texto);
      $bajada = json_encode($bajada);
      $texto = utf8_encode($texto);
      $texto = json_encode($texto);
  ?>

        {
          "id": "<? echo $ID?>",
          "titulo": "<? echo $titulo ?>",
          "bajada": <? echo $bajada ?>,
          "texto": <? echo $texto; ?>,
          "foto": "<? echo $dom?>/<? echo $carpetafoto?>/resize_<? echo $foto ;?><? echo $ext_img?>",
          "youtube": "<? echo $youtube?>",
          "url_nota": "<? echo $dom?>/nota/<? echo $ID ?>/<? echo urls_amigables($titulo) ?>"
        }

  <?} mysql_free_result($consulta);

?>
}
