I have a set of php processing pages that interact together by passing data via get, but now I have to pass JSON between a couple of the processing pages and need the same functionality as when using GET.
The current working get method:
//The guts
header("Location: $moreprocessing_url/?userid=$id");
exit();
Then in the moreprocessing_url picks up:
$userid = $_GET[id];
//More guts
$something = 'important';
header("Location: $public_url/?something=$something");
exit();
So now in the first processing page, instead of sending a simple string, I need to send JSON – so I am using CURL to post the JSON – but after the post I would like the page being posted to to continue the processing and have the original page stop. The same way the above code works but using CURL/post instead. Maybe my understanding of CURL isn’t strong enough and this just isn’t possible?
My CURL:
$curl = curl_init($moreprocessing_url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_exec($curl);
curl_close($curl);
exit();
So this returns to the current page where the CURL is happening and not the moreprocessing_url which I want — is this possible? Basically I want the page being posted to, to take over and the one sending the CURL to stop.
I believe you’re trying to do this:
If this is true then you need little tweaking to your cURL script. Something along these lines:
Depending values used for
CURLOPT_HEADERandCURLOPT_NOBODY, the$outputvariable will contain the response header, body or both (they’re separated by two blank lines). If you want something from the header, you can use regular expressions to extract the desired header and send it to the browser.OR you can echo the body should you choose to do so.