CURL
*** Initialize a cURL session
$ch = curl_init();
*** Set the URL that you want to GET by using the CURLOPT_URL option.
curl_setopt($ch, CURLOPT_URL, $url);
*** Set CURLOPT_RETURNTRANSFER so that the content is returned as a variable.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
*** Set CURLOPT_FOLLOWLOCATION to true to follow redirects.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
*** Timeout after 120 seconds
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 120);
*** Start counting time for response from BL API.
$time_start = microtime(true);
$requestTime = Carbon::now()->format('Y-m-d H:i:s');
*** Execute the request.
$response = curl_exec($ch);
*** End counting, and calculate time for response from BL API.
$time_end = microtime(true);
$responseTime = Carbon::now()->format('Y-m-d H:i:s');
$execution_time = ($time_end - $time_start)*1000;
*** Return a string containing the last error for the current session
$err = curl_error($ch);
*** Close the cURL handle.
curl_close($ch);
$ch = curl_init();
*** Set the URL that you want to GET by using the CURLOPT_URL option.
curl_setopt($ch, CURLOPT_URL, $url);
*** Set CURLOPT_RETURNTRANSFER so that the content is returned as a variable.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
*** Set CURLOPT_FOLLOWLOCATION to true to follow redirects.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
*** Timeout after 120 seconds
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 120);
*** Start counting time for response from BL API.
$time_start = microtime(true);
$requestTime = Carbon::now()->format('Y-m-d H:i:s');
*** Execute the request.
$response = curl_exec($ch);
*** End counting, and calculate time for response from BL API.
$time_end = microtime(true);
$responseTime = Carbon::now()->format('Y-m-d H:i:s');
$execution_time = ($time_end - $time_start)*1000;
*** Return a string containing the last error for the current session
$err = curl_error($ch);
*** Close the cURL handle.
curl_close($ch);
Comments
Post a Comment