-
Notifications
You must be signed in to change notification settings - Fork 106
/
test_api.php
56 lines (56 loc) · 1.38 KB
/
test_api.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
require_once 'includes/api_functions.php';
$functions = get_function_args("all");
?>
<html>
<body>
<form method=POST action="test_api.php">
<select name="method" onchange="this.form.submit()">
<?php
$methods = array('POST', 'GET');
foreach($methods as $method)
{
$is_selected = (isset($_POST['method']) and $_POST['method'] == $method)?"selected":"";
echo "<option value='$method' $is_selected>Method $method</option>";
}
?>
</select>
<br>
<select name="function" onchange="this.form.submit()">
<option value="">Select</option>
<?php
foreach($functions as $key => $value)
{
$selected = (isset($_POST['function']) and $key == $_POST['function'])?"selected":"";
echo "<option value='$key' $selected>$key</option>\n";
}
?>
</select>
</form>
<?php
if(isset($_POST['function']))
{
$get_req = $_POST['method'] == 'POST'? "?".$_POST['function']:"";
?>
<form method='<?php echo $_POST['method']; ?>' action="ogp_api.php<?php echo $get_req; ?>" target="_blank">
<?php
if($_POST['method'] == 'GET')
echo "<input type=hidden name='" . $_POST['function'] . "'>";
?>
<table>
<?php
$inputs = $functions[$_POST['function']];
foreach($inputs as $input => $mandatory)
{
$is_mandatory = $mandatory?"":" (optional)";
echo "<tr><td>". strtoupper($input) ."$is_mandatory : </td><td><input type=text name='$input'></td></tr>\n";
}
?>
<tr><td><input type=submit ></td></tr>
</table>
</form>
</body>
</html>
<?php
}
?>