Last active
February 12, 2019 04:13
-
-
Save webnitros/b8e56c0482a797c926e69ff507a72aa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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