misslilbit02 Posted October 22, 2007 Share Posted October 22, 2007 I'm receiving post from various vendors...and I'm trying to send a response back to them saying whether I received the post sucessfully or not. My thoughts were to use CURL. I'm not totally clear as to how I should handle this but this is what I did. I collected the info posted to one page then via CURL I redirected the information to another page that says wether or not the the post was successful and based on wether it was successful or not then the script is redirected to a confirmation page. My biggest issue is I'm trying to send a response to the server that posted to me saying wether or not the post was successful. Can someone please direct me in the right direction? Quote Link to comment https://forums.phpfreaks.com/topic/74350-http-post-with-curl/ Share on other sites More sharing options...
igor berger Posted October 22, 2007 Share Posted October 22, 2007 Yes you can do this with curl, take a look at curl_init and other curl function at www.php.net Quote Link to comment https://forums.phpfreaks.com/topic/74350-http-post-with-curl/#findComment-375682 Share on other sites More sharing options...
misslilbit02 Posted October 22, 2007 Author Share Posted October 22, 2007 Can someone give me an example on how to do this because this isn't working for me and i"ve never done this before. $request = ''; foreach ($_GET as $key => $value) { $value = urlencode(stripslashes($value)); if ( $body != '' ) { $body.= '&'; } $body.= "$key=$value"; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, '[url]' ); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $body); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $output = curl_exec($ch); curl_close($ch); if (strstr($output, "Success") ) { header("[url]"); } else { header("[url]"); } Where do I send the response in all of this? Quote Link to comment https://forums.phpfreaks.com/topic/74350-http-post-with-curl/#findComment-375705 Share on other sites More sharing options...
igor berger Posted October 23, 2007 Share Posted October 23, 2007 Looks correct, just pick up the data from the page you posting too using $_POST. Try posting to a page on your server... Quote Link to comment https://forums.phpfreaks.com/topic/74350-http-post-with-curl/#findComment-375879 Share on other sites More sharing options...
PyraX Posted October 23, 2007 Share Posted October 23, 2007 Had a similar problem. Its where the strstr is how you scan the resulting page to find if it succedded Quote Link to comment https://forums.phpfreaks.com/topic/74350-http-post-with-curl/#findComment-375970 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.