Other people have already asked how to do this from perl, java, bash, etc. but I need to do it in PHP, and I don't see any question already asked relating specifically to (or with answers for) PHP.
My code:
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
This doesn't work. The destination site has print_r($_GET); print_r($_POST);
, so when I examine the $result
I should be able to see the fields that are being sent. However, the $_POST array is empty - I only see the get variables. If I remove the ?...
query string from the $url, then the POST array is populated correctly. But now I don't have the GET params. How do I do this?
My specific case is, I need to send too much data to fit it in the query string, but I can't send it all as POST because the site I want to submit to is selecting a handler for the posted data based on a variable in the GET string. I can try and have that changed, but ideally I would like to be able to send both get and post data in the same query.