<?php

require "config/functions.php";
require "config/TVApi.php";
$API = new TVApi();
echo "No. of Channels: " . $API->getChannelCount() . "<br>";
echo "Channel " . $API->getChannel($API->getChannelID("FOX"))->getName();
echo "<br>Today: " . $today . "+00:00:00";
echo "<br>Tomorrow: " . $tomorrow . "+00:00:00";
$API->getChannel(4)->getPrograms($API->getChannel($API->getChannelID("FOX"))->getSigla() . "&startDate=" . $today . "&endDate=" . $tomorrow);
$API->getChannel(4)->getProgramListing();
/*

require "config/NewsApi.php";

$cm = new NewsFeed("http://www.cmjornal.xl.pt/rss.aspx");
$cm->getOutput();
*/
require "TVApi.php";
require "weatherAPI.php";
if (isset($_REQUEST["ajaxGetNews"])) {
    $request = $_REQUEST["ajaxGetNews"];
    if ($request == "CM") {
        $news = new NewsFeed("http://www.cmjornal.xl.pt/rss.aspx");
        $json = $news->getJSON();
        print $json;
    } else {
        exit;
    }
} else {
    if (isset($_REQUEST["ajaxGetTVGuide"])) {
        $channel = $_REQUEST["ajaxGetTVGuide"];
        $API = new TVApi();
        $API->getChannel(0)->getPrograms($API->getChannel($API->getChannelID($channel))->getSigla() . "&startDate=" . $today . "&endDate=" . $tomorrow);
        print $API->getChannel(0)->getJSON();
    } else {
        if (isset($_REQUEST["ajaxGetWeather"])) {
            $city = $_REQUEST["ajaxGetWeather"];
            $w = new Weather($city);
            $w->getWeather();
            $w->getWeatherForecast();
            $json_forecast = $w->getForecastJSON();
            $curWeather = $w->getCurrent();
            $curTempInterval = $w->getTempInterval();
            $curTemp = $w->getTemp();
            $cur = array();
            array_push($cur, $curWeather, $curTemp, $curTempInterval);
            $rtn = array();
            array_push($rtn, $cur, $json_forecast);