cancel
Showing results for 
Search instead for 
Did you mean: 

Response from request has syntax error using API

I'm converting the response to obj arr by json_decode but the error says it has syntax which I did not manipulate the response.

 

function sc_test_authenticate( $api_endpoint, $login, $tran_key ) {

$params = array(
'authenticateTestRequest' => array(
'merchantAuthentication' => array(
'name' => $login,
'transactionKey' => $tran_key
)
)
);

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $api_endpoint);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 300);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);

$response = curl_exec($curl);
curl_close($curl);
return json_decode($response);
}

 

this returns NULL and if I remove the json_decode this is the returned value

string(86) "{"messages":{"resultCode":"Ok","message":[{"code":"I00001","text":"Successful."}]}}"

 

Sigfred15
Member
0 REPLIES 0