Example #1
0
 public static function init()
 {
     // Setup headers
     header('Content-Type: application/json');
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     // Setup handler
     $handler = new AjaxHandler();
     $handler->registerMethod('items.get', array('LilinaAPI', 'items_get'));
     $handler->registerMethod('items.getList', array('LilinaAPI', 'items_getList'));
     $handler->registerMethod('feeds.get', array('LilinaAPI', 'feeds_get'));
     $handler->registerMethod('feeds.getList', array('LilinaAPI', 'feeds_getList'));
     $handler->registerMethod('update.single', array('LilinaAPI', 'update_single'));
     do_action_ref_array('LilinaAPI-register', array(&$handler));
     // Dispatch
     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
     try {
         $output = $handler->handle($action, $_REQUEST);
         echo json_encode($output);
     } catch (Exception $e) {
         header('HTTP/1.1 500 Internal Server Error');
         echo json_encode(array('error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()));
     }
 }
Example #2
0
 /**
  * Initialise the Ajax interface
  */
 public static function init()
 {
     $handler = new AjaxHandler();
     $handler->registerMethod('feeds.add', array('AdminAjax', 'feeds_add'));
     $handler->registerMethod('feeds.change', array('AdminAjax', 'feeds_change'));
     $handler->registerMethod('feeds.remove', array('AdminAjax', 'feeds_remove'));
     $handler->registerMethod('feeds.list', array('AdminAjax', 'feeds_list'));
     $method = isset($_REQUEST['method']) ? $_REQUEST['method'] : null;
     try {
         $output = $handler->handle($method, $_REQUEST);
         echo json_encode($output);
     } catch (Exception $e) {
         header('HTTP/500 Internal Server Error');
         echo json_encode(array('error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()));
     }
 }