Need help with authentication for rest api. creating php wrapper

116 views
Skip to first unread message

joey michael ponce

unread,
Mar 29, 2016, 9:58:20 PM3/29/16
to dcm...@googlegroups.com
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.

Joshua Paraon

unread,
Apr 1, 2016, 1:20:08 AM4/1/16
to dcm4che
I'm also having the same issue. Please help!

joey michael ponce

unread,
Apr 10, 2016, 9:17:36 PM4/10/16
to dcm4che
bump. 

any help at all? Just need to know what type of authentication is needed (basic, digest, oauth, etc...) and how to find the needed input. thank you
Reply all
Reply to author
Forward
0 new messages