本文整理汇总了PHP中Gateway::print_test_form方法的典型用法代码示例。如果您正苦于以下问题:PHP Gateway::print_test_form方法的具体用法?PHP Gateway::print_test_form怎么用?PHP Gateway::print_test_form使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gateway
的用法示例。
在下文中一共展示了Gateway::print_test_form方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle_request
public static function handle_request()
{
global $g_error_log;
global $config;
/* handle debug test mode; ?io=test */
$debug = false;
if (isset($_REQUEST['debug']) && $_REQUEST['debug'] == true) {
$debug = true;
}
if (!$config->debug && $debug) {
Util::respond_with_http_error(403, 'Forbidden');
}
if ($_REQUEST['io'] == 'test') {
$debug = true;
if (!$config->debug && $debug) {
Util::respond_with_http_error(403, 'Forbidden');
}
Gateway::print_test_form('');
exit;
}
/* normal processing of AJAX request */
Util::response_is_ajax_only();
/* log errors with custom handler and process at conclusion of request */
//set_error_handler(array('Gateway', 'custom_error_handler'));
/* in testing, it may be useful to be able to submit a request in this way */
if (isset($_REQUEST['request'])) {
$inbound = $_REQUEST['request'];
} else {
$inbound = '';
}
/* invoke the method as specified in the cmd field of the request */
$outbound = array();
try {
if ($inbound != '') {
$inbound = json_decode($inbound, true);
} else {
$inbound = json_decode(@file_get_contents('php://input'), true);
}
if ($inbound === null) {
CinsImpError::malformed('JSON input malformed');
}
$outbound['cmd'] = $inbound['cmd'];
try {
$action_method = new ReflectionMethod('Gateway', $inbound['cmd']);
} catch (Exception $err) {
throw new Exception("Gateway: Command " . $inbound['cmd'] . " unrecognised.");
}
$outbound = $action_method->invoke(null, $inbound, $outbound);
} catch (Exception $err) {
$err = new CinsImpError($err);
$outbound = array();
$outbound['cmd'] = 'error';
$outbound['msg'] = 'Server: ' . $err->getMessage() . ': ' . $err->getDetail();
$outbound['cde'] = $err->getID();
}
/* if we're debugging the gateway, output the response on the test form,
otherwise send a standard JSON response */
if ($debug) {
Gateway::print_test_form(json_encode($outbound, JSON_PRETTY_PRINT));
} else {
header('Content-type: application/json');
print json_encode($outbound);
}
}