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
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vanilla.html 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <html>
  2. <head>
  3. <meta charset="utf-8" />
  4. <script>
  5. var authUrl = 'https://php-crud-api.auth0.com/authorize'; // url of auth0 '/authorize' end-point
  6. var clientId = ''; // client id as defined in auth0
  7. var audience = 'https://your-php-crud-api/api.php'; // api audience as defined in auth0
  8. var url = '/api.php/records/posts?join=categories&join=tags&join=comments&filter=id,eq,1';
  9. function requestAPI() {
  10. var match = RegExp('[#&]access_token=([^&]*)').exec(window.location.hash);
  11. var accessToken = match && decodeURIComponent(match[1].replace(/\+/g, ' '));
  12. if (!accessToken) {
  13. document.location = authUrl+'?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+document.location.href;
  14. } else {
  15. document.location.hash = '';
  16. var req = new XMLHttpRequest();
  17. req.onreadystatechange = function () {
  18. if (req.readyState==4) {
  19. console.log(req.responseText);
  20. try {
  21. document.getElementById('output').innerHTML = JSON.stringify(JSON.parse(req.responseText), undefined, 4);
  22. } catch (error) {
  23. document.getElementById('output').innerHTML = req.responseText;
  24. }
  25. }
  26. }
  27. req.open("GET", url, true);
  28. req.setRequestHeader('X-Authorization', 'Bearer '+accessToken);
  29. req.send();
  30. }
  31. };
  32. window.onload = function() {
  33. requestAPI()
  34. document.getElementById('request-btn').onclick = function(e) {
  35. e.preventDefault()
  36. requestAPI()
  37. }
  38. }
  39. </script>
  40. </head>
  41. <body>
  42. <p>
  43. <button type="button" id="request-btn">Request API</button>
  44. </p>
  45. <pre id="output"></pre>
  46. </body>
  47. </html>