testcurl.php 905 B

123456789101112131415161718192021222324
  1. <?php
  2. require_once '../config/config.inc.php';
  3. $url = SYNC_URL.'testcurl_dest.php';
  4. $SYNC_AGENT = 'Dolibarr API Test';
  5. $timeout = '30';
  6. $post = $_POST;
  7. echo '<p>'.$url.'</p>';
  8. $ch = curl_init($url); // initialize curl with given url
  9. //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set useragent
  10. curl_setopt($ch, CURLOPT_USERAGENT, $SYNC_AGENT);
  11. curl_setopt($ch, CURLOPT_TIMEOUT_MS, 250);
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable
  13. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any
  14. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds to execute
  15. curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error
  16. curl_setopt($ch, CURLOPT_POST, true);
  17. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
  18. $raw_data = curl_exec($ch);
  19. echo $raw_data; //die();
  20. echo '<p>END</p>';