Example #1
0
 public static function parseRequest(&$wp)
 {
     if (array_key_exists('rm_anonses_api', $wp->query_vars)) {
         if ($_SERVER['HTTP_USER_AGENT'] != 'rm-bot/1.0') {
             wp_redirect(home_url(), 403);
             exit;
         }
         $ds = isset($wp->query_vars['rm_anonses_date_start']) ? $wp->query_vars['rm_anonses_date_start'] : NULL;
         $de = isset($wp->query_vars['rm_anonses_date_end']) ? $wp->query_vars['rm_anonses_date_end'] : NULL;
         $ts = isset($wp->query_vars['rm_anonses_time_start']) ? $wp->query_vars['rm_anonses_time_start'] : NULL;
         $te = isset($wp->query_vars['rm_anonses_time_end']) ? $wp->query_vars['rm_anonses_time_end'] : NULL;
         $count = isset($wp->query_vars['rm_anonses_count']) ? $wp->query_vars['rm_anonses_count'] : 10;
         $w = new Model();
         $args = array('date_start' => $ds, 'date_end' => $de, 'time_start' => $ts, 'time_end' => $te, 'count' => $count);
         $ret = $w->getTVprogramsApi($args);
         ob_clean();
         header('Content-Type: application/json; charset=UTF-8');
         echo json_encode($ret);
         exit;
     }
 }