Example #1
0
if (array_key_exists("channel", $_GET)) {
    $channel = $_GET["channel"];
}
$date = time() + 3600 * 8;
if (array_key_exists("date", $_GET)) {
    $date = DateTime::createFromFormat('Y-m-d', $_GET["date"])->getTimestamp();
    $date = $date + 3600 * 8;
    if ($date > time() + 3600 * 8) {
        $date = time() + 3600 * 8;
    }
}
$refresh = false;
if (array_key_exists("r", $_GET)) {
    if ($_GET["r"] == "1" or $_GET["r"] == "true") {
        $refresh = true;
    }
}
$cc = BaseChannel::createChannel($channel);
$ret = $cc->getRadio($date);
$count = 0;
while ($ret == null && $count < 10) {
    //查询历史十天内的数据
    $date = $date - 3600 * 24;
    $ret = $cc->getRadio($date);
    $count++;
}
if ($ret == null) {
    die("Something is wrong about this channel.");
}
header('Content-type: application/json;text/html;charset=utf-8;');
echo json_encode($ret);