forked from jquery/testswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApiDebugPage.php
56 lines (42 loc) · 1.05 KB
/
ApiDebugPage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Api Debug handler.
*
* @author Timo Tijhof, 2012
* @since 1.0.0
* @package TestSwarm
*/
class ApiDebugPage extends Page {
protected $apiResponse;
protected function initContent() {
if ( !defined( 'SWARM_ENTRY' ) || SWARM_ENTRY !== 'API' ) {
echo "This page is not viewable outside the scope of the API.\n";
exit;
}
$this->setTitle( "API Response" );
$this->setRobots( "noindex,nofollow" );
$html = "";
$html .= "<h3>Request <small><code>wasPosted: " . (
$this->getContext()->getRequest()->wasPosted()
? "true"
: "false"
) . "</code></small></h3>";
$html .= "<pre>";
ob_start();
var_dump( $_POST + $_GET );
$html .= htmlspecialchars( ob_get_contents() );
ob_end_clean();
$html .= "</pre>";
$html .= "<h3>Response</h3>";
$html .= "<pre>";
ob_start();
var_dump( $this->apiResponse );
$html .= htmlspecialchars( ob_get_contents() );
ob_end_clean();
$html .= "</pre>";
return $html;
}
public function setApiResponse( Array $apiResponse ) {
$this->apiResponse = $apiResponse;
}
}