Re: [PHP] load a URL and trap output
simple use fopen() or file() as $fp = fopen(http://somedomain/some.url?blablah,r;); and read via fread() /tom On Fri, 12 Mar 2004 10:54:53 -0500 Roger Spears [EMAIL PROTECTED] wrote: Hello, I have this application which is accessed via a web portal. The first thing my application must do is make sure the visitor is logged in via the portal. The only way to do this is by making a request to a specific URL. This URL (which includes the log in cookie id) will return XML to my application. Once I parse this XML, I will know if visitors are logged in. Simple enough. How do I make my application load a URL and trap the returned data so that it never creates any browser output? My first reaction was header(Location: URL) but then I'd be handing off control to the URL and the output would appear in the browser. I've done some research and found system(), exec(), and passthru(). But I'm not sure if these functions are the proper way to do such a task especially since I'm calling a URL and not a specific UNIX command. Thanks, Roger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load a URL and trap output
How do I make my application load a URL and trap the returned data so that it never creates any browser output? Aside from the fopen() and fread() that was suggested by another person you can also use the ob_* functions. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load a URL and trap output
Best way would be filegetcontents() and implode the content with \n. eg: ?php $temp = filegetcontents('http://www.somedomain.com'); $temp = implode ( \n , $temp ); echo $temp ; ? Chris Boget wrote: How do I make my application load a URL and trap the returned data so that it never creates any browser output? Aside from the fopen() and fread() that was suggested by another person you can also use the ob_* functions. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load a URL and trap output
Tom Meinlschmidt wrote: simple use fopen() or file() as $fp = fopen(http://somedomain/some.url?blablah,r;); and read via fread() Then I replied with: Perhaps I was mistaken, I thought: $fp = fopen(http://somedomain/some.url?blablah,r;); fread(); Would just return the actual HTML code of the page and NOT the results of running the page?.?.?.?.? I will test it out and see. Thank you for your suggestion! Hello All, It seems fopen() did not work. However, it did stop the FORBIDDEN message I was receiving. So I think I'm on the right track. Here's what I tried... $filename = actual URL; $fd = fopen($filename, r); $contents = fread($fd, $filename); fclose($fd); print strlen($contents); print p.$contents; I can open the URL, that works ( fopen() ). I've tested out the fread(), file(), fgets(), and file_get_contents functions. Nothing works. I can close the URL, that works ( fclose() ). With each attempt, I get 0 for the strlen of $contents and nothing else prints out. I also tried adding this to the script right before fopen: ini_set('allow_url_fopen','1'); That didn't work either... Any idea(s) on what I'm doing wrong? I'm using php 4.3.3 and I believe it's Apache 1.3 Thanks, Roger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php