PDA

View Full Version : Grabbing secure content with fopen and fread


Alex
December 12th, 2004, 10:30
I'm trying to get my dialup time usage from my ISP's website. It has a secure login. Here is what I have to connect and get the content:

<?php
$url = fopen("https://user:pass@www.domain.com", "r");
$res = fread($url, 90000);
?>

It doesnt seem to work... :

Warning: fopen(https://...@www.domain.com): failed to open stream: Invalid argument in path\to\file.php on line 7
Warning: fread(): supplied argument is not a valid stream resource in path\to\file.php on line 8


Any ideas on how I could make this work? :cry:

sonicgroup
December 12th, 2004, 14:20
Does your PHP installation support allow_url_fopen? Is you PHP installation compiled with SSL support (necessary for HTTPS)?

If both of those are correct, then check this out from the PHP manual on the fopen wrappers: http://us3.php.net/manual/en/wrappers.http.php .

Alex
December 13th, 2004, 22:09
allow_url_fopen is on and ssl is installed aswell, I think, here's my phpinfo:
http://www.polarhome.com:793/~dirmass/php/phpinfo.php.htm

dam that manual confuses me more... I still don't see the solution...

sonicgroup
December 14th, 2004, 01:27
Well, you can't use fread() on a stream (that's what this is), so I'd suggest taking a look at the Stream Functions (http://us3.php.net/manual/en/ref.stream.php). In particular, check out stream_get_contents().