I am trying to implement VISA Developer Foreign Exchange API using CURL but when i send a request, i get Authentication Error message. I am testing the API locally and here is my implementation to it.
$data_string = $_POST;
$ch = curl_init('https://sandbox.api.visa.com/forexrates/v1/foreignexchangerates');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', "Accept:application/json", "Authorization:".base64_encode("usernamestring:passwordstring")));
curl_setopt($ch, CURLOPT_URL, "https://sandbox.api.visa.com/forexrates/v1/foreignexchangerates");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data_string));
curl_setopt($ch, CURLOPT_POST, 1);
$results = curl_exec($ch);
They also generate a .pem certifcate which i am not sure if i have to use for Foreign Exchnage API request but can you please have a look and see if i am doing anything wrong?