Hello,
I'm having problems taking everything that is posted to a page and sending it via cURL... I just can't figure it out... how do I take everything posted to pageA and send it to pageB on a different server.... each time the POST has different information..
Thanks!
cURL Post Foward
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: cURL Post Foward
What part is not working? You need to take the $_POST vars and build a cURL request from them. See the manual or be more specific on where the problem is occurring.
(#10850)
Re: cURL Post Foward
I didn't know you could make HTTP POST requests with cURL? I thought your only option was fsockopen.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: cURL Post Foward
cURL has options: CURLOPT_HTTPGET, CURLOPT_POST, CURLOPT_PUT, plus CURLOPT_CUSTOMREQUEST.
(#10850)
Re: cURL Post Foward
Awesome! Thanks arborint for that epiphany!
I managed to wip up a cURL that sends POST requests to a page. If you want all the $_POST fields to be sent to another page that's on another server try something like this:
Something like that. You can also only send individual fields by redefining the $data definition:
Just as long as $data is an array it'll work.
Hope that helps.
I managed to wip up a cURL that sends POST requests to a page. If you want all the $_POST fields to be sent to another page that's on another server try something like this:
Code: Select all
<?php
$data = $_POST;
$ch = curl_init("http://url.com/path/file");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CUROPT_POSTFIELDS, $data));
curl_exec($ch)
curl_close($ch);
?>
Code: Select all
$data = array("name" => $_POST['name'], "whatever" => $_POST['whatever']);
Hope that helps.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US