Hello,
I am currently trying to make a php wrapper for dcm4che and was wondering how to access data using the api. I'm not sure if there is already a similar post about this but I couldn't find one when i looked. I've tried using curl and file_get_contents to try and extract the json output but even with authentication details it still asks for login details. I've tried:
//curl
$ch = curl_init();
$user = "myuser";
$pass = "mypass";
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
as well as:
//file_get_contents
$username = 'myuser';
$password = 'mypass';
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);
print_r($data);
They just return a login form and when i try to enter the login details, that returns a Bad Request. I was hoping to ask how to handle the authentication to be able to get the json file.