I am trying to integrate an API on my website and it requires me to post an authorization field which is encoded in base64. However, it is saying that I am not doing it correctly. I wonder if it is because I am not posting the field correctly. This is what I have done so far.
$pro = '00000000000';
$host = 'http://www.saiasecure.com/irsec/getimginfo1.aspx?refNumber='.$pro;
$authorization = 'username : password';
$authorization = base64_encode($authorization);
$post = array(
'Authorization' => $authorization
);
$ch = curl_init($host);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$return = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($return);
try
{
print_r($xml);
} catch(SoapFault $ex){
$ex->getMessage();
echo $ex;
}
These are the API instructions provided by the developer.
This is the response I get from the API:
Does anybody know what I'm doing wrong? It is driving me crazy!