Web Hosting Talk







View Full Version : Can't fopen & fgets WebHostingTalk


jasong
07-17-2005, 11:11 PM
Hi all,

For some odd reason, I am unable to use fopen and fgets with PHP with webhostingtalk.com

I am able to do it with any other sites, but not WHT for some reason.

Here is what I'm using:

$pageurl='http://www.webhostingtalk.com/search.php?s=';
$handle = fopen("$pageurl", "r");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$pagecontents.= $buffer;
}
print "$pagecontents";
fclose($handle);


Could anybody try this code out on their servers to see if they are able to?

Thanks,
Jason

tiamak
07-17-2005, 11:49 PM
You cant fopen it :)
Use fsockopen instead
You will require to add User-Agent header.
Without it connection will be closed.

btw i hope you need it only for testing purpose or some Legal stuff :)

regards
Tom

jasong
07-18-2005, 01:36 AM
Originally posted by tiamak
You cant fopen it :)
Use fsockopen instead
You will require to add User-Agent header.
Without it connection will be closed.

Why am I able to use it for other sites and not this one? It's the only one that it hasn't worked for.

btw i hope you need it only for testing purpose or some Legal stuff :)

It's not actually being used for anything. I'm just testing a script I am making that will work with different sites, and I figured I'd test it on WHT.

Thanks for the help :)
-Jason

tiamak
07-18-2005, 01:49 AM
it seems that for some reason (maybe to prevent lame data mining?) admins here restricted access only to those programs that connect providing some headers (like User-Agent)

certainly this is not fault of your script - its just WHT smart configuration.