Skip to content

Instantly share code, notes, and snippets.

@webnitros
Last active February 12, 2019 04:13
Show Gist options
  • Save webnitros/b8e56c0482a797c926e69ff507a72aa9 to your computer and use it in GitHub Desktop.
Save webnitros/b8e56c0482a797c926e69ff507a72aa9 to your computer and use it in GitHub Desktop.
<?php
//ini_set('display_errors', 1);
//ini_set("max_execution_time", 20);
// Boot up MODX
require_once dirname(dirname(__FILE__)) . '/config.core.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError', '', '');
// Boot up any service classes or packages (models) you will need
// Load the modRestService class and pass it some basic configuration
/* @var modRestService $rest */
$rest = $modx->getService('rest', 'rest.modRestService', '', array(
'basePath' => dirname(__FILE__) . '/Controllers/',
'controllerClassSeparator' => '',
'controllerClassPrefix' => 'MyController',
'xmlRootNode' => 'response',
));
$modx->initialize('web');
// Prepare the request
$rest->prepare();
// Make sure the user has the proper permissions, send the user a 401 error if not
if (!$rest->checkPermissions()) {
$rest->sendUnauthorized(true);
}
// Run the request
$rest->process();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment