1

Currently the below code causes a resubmission of the JSON POST to the URL creating duplicate records server side. I have suspicions it may be how im attempting to display the results.

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "API-URL",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $final_JSON,
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Content-Type: application/json"
  ),
));

$response2 = curl_exec($curl);

curl_close($curl);
$get_results = json_decode($response2);

echo $get_results->ResultString;
if($get_results->HTMLResponsePage != ""){
echo $get_results->HTMLResponsePage;
}

The JSON POST sends a response back in the format of

{"AuthCode":null,"HTMLResponsePage":null,"OrderID":0,"PaymentType":0,"PaypalURL":null,"Result":-6,"ResultString":"Required Date\/Time is in the Past. Select a Future Time.","ThreeDSecureURL":null,"TransactionID":null}

I need to echo just the "HTMLResponsePage" section, currently trying $get_results->HTMLResponsePage; doesn't provide a correct result.

EDIT - an attempt of echo $response2- >HTMLResponsePage; Also fails to provide a correct result!

UPDATE - seems to run ok through google chrome! I have tried spoofing the user agent and it still won’t run just once through safari!

UPDATE - Have tried most variations of user agents that are available. I am wondering if I should find another way of sending the JSON POST.

UPDATE - Tried various other methods with still no luck getting a single submission rather than duplicate. Any Suggestions?

Grew
  • 13
  • 4

0 Answers0