Reputation: 12262
$data = array();
$handle = curl_init($api_url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$result=curl_exec($handle);
I am too experienced with curl and debugging this code. The data gets posted successfully to the api url, but there is reports of the data being sent to the api 2 to 3 times each. I want to rule out the code above being the problem as I investigate potential a slow loading form after the user clicks submit, some users may click the submit button a couple times due to the form delay.
Do you see anything above that would reveal it being posted the same data two or three times?
Upvotes: 1
Views: 1297
Reputation: 72965
Reviewing the OP code, it is a solid (and very simple) php curl expression.
The suggestion is to create a simple logger right before the curl is initiated (or in this case an echo
).
This way, one can easily distinguish between the following:
If you see one log line for each dupe, the cause is 1. If you see only one log line for the entire set of dupes, then the cause is 2.
Upvotes: 2