1

i need to post raw data (XML) to an external site, the XML data is good to go, and is working with the below example...

I am using PHP / cURL

normally i do this by cURL, but in this instance, i need to redirect the client to the URL with the post data...

It works using the below code, but it won't redirect the user to the $URL, this method just prints the data while still being in the script on the same server.

eg: Post from site1.com to site2.com, the below method keeps the client on site1, but needs to redirect the user to site2.com with the raw post data...

$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_xml); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$val = curl_exec($ch);  
curl_close($ch);

i have searched all-over but cannot find a method where it functions as a "regular" form submit where the user is redirected to the URL which the data is posted to... but with RAW post data.

Shibu
  • 486
  • 1
  • 11
  • 20
  • i'm voting to close this as too broad because it seems to be 2 questions, 1: how to hide curl_exec()'s response from the browser (which can be done with CURLOPT_NOBODY), and 2: how to redirect the browser to another url (which can be done with [http Location redirects](https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections)) , and i believe both of these questions are already answered elsewhere on SO – hanshenrik Nov 24 '18 at 11:11

0 Answers0