test_api.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. require_once 'includes/api_functions.php';
  3. $functions = get_function_args("all");
  4. ?>
  5. <html>
  6. <body>
  7. <form method=POST action="test_api.php">
  8. <select name="method" onchange="this.form.submit()">
  9. <?php
  10. $methods = array('POST', 'GET');
  11. foreach($methods as $method)
  12. {
  13. $is_selected = (isset($_POST['method']) and $_POST['method'] == $method)?"selected":"";
  14. echo "<option value='$method' $is_selected>Method $method</option>";
  15. }
  16. ?>
  17. </select>
  18. <br>
  19. <select name="function" onchange="this.form.submit()">
  20. <option value="">Select</option>
  21. <?php
  22. foreach($functions as $key => $value)
  23. {
  24. $selected = (isset($_POST['function']) and $key == $_POST['function'])?"selected":"";
  25. echo "<option value='$key' $selected>$key</option>\n";
  26. }
  27. ?>
  28. </select>
  29. </form>
  30. <?php
  31. if(isset($_POST['function']))
  32. {
  33. $get_req = $_POST['method'] == 'POST'? "?".$_POST['function']:"";
  34. ?>
  35. <form method='<?php echo $_POST['method']; ?>' action="ogp_api.php<?php echo $get_req; ?>" target="_blank">
  36. <?php
  37. if($_POST['method'] == 'GET')
  38. echo "<input type=hidden name='" . $_POST['function'] . "'>";
  39. ?>
  40. <table>
  41. <?php
  42. $inputs = $functions[$_POST['function']];
  43. foreach($inputs as $input => $mandatory)
  44. {
  45. $is_mandatory = $mandatory?"":" (optional)";
  46. echo "<tr><td>". strtoupper($input) ."$is_mandatory : </td><td><input type=text name='$input'></td></tr>\n";
  47. }
  48. ?>
  49. <tr><td><input type=submit ></td></tr>
  50. </table>
  51. </form>
  52. </body>
  53. </html>
  54. <?php
  55. }
  56. ?>