I'm connecting up to an API via the following method however it is returning a "unauthorized" response. This is to validate the user credentials and return a response. I am trying to connect to a Way-2 with LDAP although I'm not a C# person.
<?php
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
$service_url = 'http://www.myurl.com/webservices/getuser';
$curl = curl_init($service_url);
$curl_post_data = array(
"username" => 'mywebservice', //
"password" => 'wspass', //
"UserProfileID" => 'weiuYhJxmeoQLsKvviPNzr==',
"Name" => 'John'
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
curl_close($curl);
echo "Data: ";
$xml = new SimpleXMLElement($curl_response);
echo $xml;
?>
In essence it should connect up to the webservice with the username and password as specified above, then a POST request is made to the $service_url with the following parameters:
Request XML
<xml>
<UserProfileID>weiuYhJxmeoQLsKvviPNzr==</UserProfileID>
<Name>John</Name>
</xml>
Example of Valid Response XML
<xml>
<UserProfileID>weiuYhJxmeoQLsKvviPNzr==</UserProfileID>
<Name>John</Name>
<ProfileImage>http://www.myurl.com/profile_image/dfkjd.png</ProfileImage>
</xml>
How can I modify my PHP accordingly to connect properly and get this working, and actually responding with the valid XML response for that user? Thanks