mrfitz Posted March 27, 2009 Share Posted March 27, 2009 ??? ??? Need a little help... I use CURL to send headers to a script on another website (other domain where the script is running on). At the end of the script I do a return and the results from the script are displayed on the Calling webpage. The problem is the I am returning a comma delimited string and it just displays the string on the webpage. I would really like to be able to grab the string without displaying it, then parse it into fields and display it in a table, but the script does not come back into a field. It just displays on the page, I can't seem to capture it into a "receiving" string that I can parse out. The question is ... How do I get the response back into a string that I can parse? Here is a snip of the "end" of the script on the domain I am getting the response string from: ////// default: $error_code = 3; $output = "0,0,0," . error_report($error_code).";"; fwrite($log, "OUT Vals: " . $output . "\r\n\r\n"); } fclose ($log); return; ?> /////// as you can see it is just a simple "return;". A snip of the calling web page's script is here: ///////////////// function get_bal2(){ ?> <div align="center" class="content"> <h1>Balance Request</h1> <h2>Current Balance</h2> </div> <?php send_request(); return; } function send_request(){ $req = $_POST; array_pop($req); $URL="xxxxxxxxx.com/yyyyyyy/rrrrr.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://$URL"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_exec ($ch); curl_close ($ch); return; } /////////////////////// and here is a screen scrape of the result webpage: //////////////////// Balance Request Current Balance 25.00,2009-03-22,1; //////////////////// As you can see the response sting is there but is displayed as it is sent from the script on the domain I am getting the response string from. Please help. Thanks in advance, Mrfitz Link to comment https://forums.phpfreaks.com/topic/151319-solved-how-do-i-format-a-script-response-to-a-website-post/ Share on other sites More sharing options...
mrfitz Posted March 27, 2009 Author Share Posted March 27, 2009 Fixed my own problem with: function send_request(){ $req = $_POST; array_pop($req); $URL="zzzzzzzzzzz.com/yyyyyyyyy/xxxxxxxx.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://$URL"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // $output contains the output string $output = curl_exec($ch); curl_close ($ch); return($output); } just call this and it works!! Link to comment https://forums.phpfreaks.com/topic/151319-solved-how-do-i-format-a-script-response-to-a-website-post/#findComment-795175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.