api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
Ви не можете вибрати більше 25 тем Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require "../lib/php_crud_api_transform.php";
  3. function call($method, $url, $data = false) {
  4. $ch = curl_init();
  5. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  6. curl_setopt($ch, CURLOPT_URL, $url);
  7. if ($data) {
  8. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  9. $headers = array();
  10. $headers[] = 'Content-Type: application/json';
  11. $headers[] = 'Content-Length: ' . strlen($data);
  12. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  13. }
  14. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  15. return curl_exec($ch);
  16. }
  17. $response = call('GET', 'http://localhost/api.php/posts?include=categories,tags,comments&filter=id,eq,1');
  18. $jsonObject = json_decode($response, true);
  19. $jsonObject = php_crud_api_transform($jsonObject);
  20. $output = json_encode($jsonObject, JSON_PRETTY_PRINT);
  21. ?>
  22. <html>
  23. <head>
  24. </head>
  25. <body>
  26. <pre><?php echo $output ?></pre>
  27. </body>
  28. </html>