Hello team,
I have the following code in PHP and whenever I run it from my cpanel server, the result is always false. Could it be as a result of security or something else? Do not mind the URL and credentials, those are wrong I just wanted to demonstrate my problem.
<?php
header("access-control-allow-origin: *");
$username = 'admin';
$password = 'Pass*#21_!';
$url='http://12.113.12.186:8083/api/dataValueSets.json?dataSet=%&period=%&orgUnit=%';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_USERPWD, "".$username.":".$password."");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
The same code is working perfectly well for URLs which are in letters and don’t have a port number like:
<?php
header("access-control-allow-origin: *");
$username = 'admin';
$password = 'district';
$url='https://play.dhis2.org/2.34.0/api/dataValueSets.json?dataSet=%&period=%&orgUnit=%';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_USERPWD, "".$username.":".$password."");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
The result is : {“httpStatus”:“Conflict”,“httpStatusCode”:409,“status”:“ERROR”,“message”:“At least one valid organisation unit or organisation unit group must be specified”}
This is exactly the result that I want for the URL with numbers and a port.