Before we updated our myDBR version, it worked.
We would use the following cURL from our PHP code to run a report:
public static function generateReportFromUrl(string $url, string $report_type = null)
{
if (!is_null($report_type)) {
$url = $url . "&export=" . $report_type;
}
$ch = curl_init();
if (!(is_resource($ch) && get_resource_type($ch) === 'curl'))
{
throw new \Exception("cURL Error: ailed to initialize cURL.");
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Note: THIS SETTING DOES NOT SOLVE THE PROBLEM
// Get the config setting for the global myDBR user id and password
$userId = Yii::$app->params['mydbr_global_user_id'];
$userPassword = Yii::$app->params['mydbr_global_user_password'];
$credentials = $userId . ":" . $userPassword; curl_setopt($ch, CURLOPT_USERPWD, $credentials);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-MYDBR-AUTH: 1'));
$file = curl_exec($ch);
if ($file === false)
{
$error_msg = curl_error($ch);
$error_no = curl_errno($ch);
curl_close($ch);
// Exception will be handled by parent BaseAutomationException
throw new \Exception("cURL Error: [$error_no] - $error_msg");
}
else
{
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode >= 400) {
throw new \Error("Report Request Error. HTTP error " . $httpCode);
}
else if ($file == "") {
// Note For some reason Curl returns empty on my local VM
throw new \Error("Report Request Error. Unable to retrieve report data");
}
}
return $file;
}
After we update the version, the content from myDBR is returning the empty string without triggering errors.
Here is the info returned from curl_info()
(
[url] => https://apps.verifacto.com/mydbr/report.php?r=sp_DBR_removed_cpi_full_report&h=80dab4b126b246482eb51a48aed078d028074c5c900f2741bbb383131a0db91a&p1=%60tx-ctc%60&u2=((ALL))&u3=((ALL))&u4=((ALL))&u5=((ALL))&u6=2023-11-16&u7=2023-11-16&hdr=0&export=CSV
[content_type] => text/html; charset=UTF-8
[http_code] => 302
[header_size] => 588
[request_size] => 382
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.213583
[namelookup_time] => 0.000325
[connect_time] => 0.000789
[pretransfer_time] => 0.020738
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => -1
[starttransfer_time] => 0.213558
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 44.208.208.71
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => 192.168.10.105
[local_port] => 45778
[http_version] => 2
[protocol] => 2
[ssl_verifyresult] => 0
[scheme] => HTTPS
[appconnect_time_us] => 20700
[connect_time_us] => 789
[namelookup_time_us] => 325
[pretransfer_time_us] => 20738
[redirect_time_us] => 0
[starttransfer_time_us] => 213558
[total_time_us] => 213583
)
Please note that if we copy the above URL and paste it into the browser the report content is returned as expected.
https://apps.verifacto.com/mydbr/report.php?r=sp_DBR_removed_cpi_full_report&h=80dab4b126b246482eb51a48aed078d028074c5c900f2741bbb383131a0db91a&p1=%60tx-ctc%60&u2=((ALL))&u3=((ALL))&u4=((ALL))&u5=((ALL))&u6=2023-11-16&u7=2023-11-16&hdr=0&export=CSV
But again, before we updated our myDBR version, even using cURL worked as expected.