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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

client.php 855B

12345678910111213141516171819202122232425262728293031
  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>