aximbigfan Posted April 28, 2008 Share Posted April 28, 2008 Hi... I have a PHP script that is suppose to post to another server, and then return the response. The big problem here is that it is also returning the headers from the other server, so I put tags around the output, and am tryign to parse what is between the tags. I have that part down, but this simply is not working. The tags are all there, and when the tag code is taken out, it works fine, but it will then output the headers too, which I just don't want as it contaminates the output. So... 1. Can I do something else so that the headers are NOT returned? 2. If not, how can I parse the tags right? Here is the code function remotereg($host, $path, $mode, $cat=null, $key=null, $val=null, $ueo=null ) { $http_response = ""; $data = "mode=$mode&cat=$cat&key=$key&val=$val"; $content_length = strlen($data); $fp = fsockopen($host, 80); fputs($fp, "POST $path HTTP/1.0\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-Length: $content_length\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); while (!feof($fp)) $http_response .= fgets($fp, 28); fclose($fp); return $http_response; //Parse tags $start = "ret"; $end = "/ret"; $parsein = http_response; $parseout = ""; $pos_s = strpos($parsein, $start); $pos_e = strpos($text, $end); for ($i=$pos_s+strlen($start) ; (( $i<($pos_e)) && $i <strlen($parsein)) ; $i++) { $parseout .= $text[$i]; } $http_response = $parseout; return $http_response; } Thanks! Chris Link to comment https://forums.phpfreaks.com/topic/103213-solved-using-php-to-post-to-other-server-ok-except-for-response-text/ Share on other sites More sharing options...
aximbigfan Posted April 28, 2008 Author Share Posted April 28, 2008 Also, I do know about how I forgot the $ in front of http_response in one of the lines. I corrected it, and that is not the issue, it still does not work. Chris Link to comment https://forums.phpfreaks.com/topic/103213-solved-using-php-to-post-to-other-server-ok-except-for-response-text/#findComment-528685 Share on other sites More sharing options...
aximbigfan Posted April 28, 2008 Author Share Posted April 28, 2008 Never mind. Problem solved. I just created a whole new method to split stuff around explode(). Chris Link to comment https://forums.phpfreaks.com/topic/103213-solved-using-php-to-post-to-other-server-ok-except-for-response-text/#findComment-528707 Share on other sites More sharing options...
jonsjava Posted April 28, 2008 Share Posted April 28, 2008 Could you mark this thread resolved, please? Link to comment https://forums.phpfreaks.com/topic/103213-solved-using-php-to-post-to-other-server-ok-except-for-response-text/#findComment-528710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.