call-api.php 831 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. require_once 'HTTP/Request2.php';
  3. $request = new HTTP_Request2();
  4. $request->setUrl('https://prtg.easytelecoms.fr:1616/api/v2/sensors?offset=0&limit=100&filter=&sort_by=&include_all_channels=true');
  5. $request->setMethod(HTTP_Request2::METHOD_GET);
  6. $request->setConfig(array(
  7. 'follow_redirects' => TRUE,
  8. 'ssl_verify_peer' => false,
  9. 'ssl_verify_host' => false
  10. ));
  11. $request->setHeader(array(
  12. 'Accept' => 'application/json',
  13. 'Authorization' => 'Bearer H57EHLEJBRNAOPH5NRQGKEJRJX4BRTLQ3FVJ7ZAPE4======'
  14. ));
  15. try {
  16. $response = $request->send();
  17. if ($response->getStatus() == 200) {
  18. echo $response->getBody();
  19. }
  20. else {
  21. echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
  22. $response->getReasonPhrase();
  23. }
  24. }
  25. catch(HTTP_Request2_Exception $e) {
  26. echo 'Error: ' . $e->getMessage();
  27. }
  28. ?>