本文整理汇总了PHP中RequestHandler::process方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestHandler::process方法的具体用法?PHP RequestHandler::process怎么用?PHP RequestHandler::process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestHandler
的用法示例。
在下文中一共展示了RequestHandler::process方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
public static function processRequest()
{
global $logger;
$request = $rawResponse = $response = null;
try {
/* Authenticate */
$valid = self::authenticateRequest($_SERVER);
/* Fetch POST data */
$post = file_get_contents("php://input");
$logger->debug("POST Data Received: " . $post);
/* Formulate the request object */
$request = RequestParser::parseInput($_SERVER, $_GET, $post);
$logger->debug("REQUEST Object: " . $request->toString());
/* Handle the request */
$rawResponse = RequestHandler::process($request);
$logger->debug("RESPONSE Object: " . json_encode($rawResponse));
} catch (ApiException $e) {
/* Generate response from Exception details */
$logger->error("ApiException encountered!! " . $e->toString());
$rawResponse = array('httpStatusCode' => $e->getHttpStatusCode(), 'httpStatusCodeMessage' => $e->getHttpStatusCodeMessage(), 'otherHeaders' => $e->getOtherHeaders(), 'code' => $e->getCode(), 'message' => $e->getMessage(), 'debug' => false, 'data' => null);
}
// Format the $rawResponse variable and output
$format = !isset($request) ? 'json' : $request->getFormat();
$debug = !isset($request) ? false : $request->getDebug();
$response = ResponseHandler::respond($rawResponse, $format, $debug);
$logger->debug("Output: " . $response);
}