123456789101112131415161718192021222324 |
- <?php
- require_once '../config/config.inc.php';
- $url = SYNC_URL.'testcurl_dest.php';
- $SYNC_AGENT = 'Dolibarr API Test';
- $timeout = '30';
- $post = $_POST;
- echo '<p>'.$url.'</p>';
- $ch = curl_init($url); // initialize curl with given url
- //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set useragent
- curl_setopt($ch, CURLOPT_USERAGENT, $SYNC_AGENT);
- curl_setopt($ch, CURLOPT_TIMEOUT_MS, 250);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds to execute
- curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
- $raw_data = curl_exec($ch);
- echo $raw_data; //die();
- echo '<p>END</p>';
|