api.php 679 B

123456789101112131415161718192021222324
  1. <?php
  2. //session_start();
  3. header("Access-Control-Allow-Origin: *");
  4. header("Access-Control-Allow-Headers: authorization, cache-control, x-requested-with, rayid");
  5. header("Access-Control-Allow-Methods: *");
  6. header("Content-Type: application/json; charset=utf-8");
  7. require_once 'IIMTAPI.class.php';
  8. // Requests from the same server don't have a HTTP_ORIGIN header
  9. if (!array_key_exists('HTTP_ORIGIN', $_SERVER)) {
  10. $_SERVER['HTTP_ORIGIN'] = $_SERVER['SERVER_NAME'];
  11. }
  12. try {
  13. $API = new IIMTAPI($_REQUEST['request'], $_SERVER['HTTP_ORIGIN']);
  14. echo $API->process();
  15. }
  16. catch (Exception $e) {
  17. echo json_encode(Array('error' => $e->getMessage()));
  18. }
  19. ?>