For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > January 2007 > Reading a page with file() - Problems with https









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Reading a page with file() - Problems with https
Cord-Heinrich Pahlmann

2007-01-28, 9:59 pm

Hi,

I need the HTML content of an extern webpage.
Normally I just use file(http://externpage); to read the contents.
But with file(httpS://externpage); i get an error.
The script is running under http://, so that is probably the problem
since http can't send to https (right?).

Is there some workarround. I just need the the <form> data from the
extern page.

Thx, for any suggestions.

Joachim Mæland

2007-01-28, 9:59 pm

On Sun, 28 Jan 2007 12:20:25 -0800, Cord-Heinrich Pahlmann wrote:

> But with file(httpS://externpage); i get an error.


What kind of error...?

What OS and webserver is the remote site running?

What OS, PHP version and webserver is your local site running?

> The script is running under http://, so that is probably the problem
> since http can't send to https (right?).


No..! HTTP/HTTPS is a question of unencrypted or encrypted communication
between PHP running the script with the file() function and the remote
site. How you invoked the script is not an issue.

> Thx, for any suggestions.


Ditto, for anything resembling a clue of what you're experiencing... ;-)

--
Regards/mvh Joachim Mæland

If everything seems under control, you're just not going fast enough.
-Mario Andretti.

Michael Fesser

2007-01-28, 9:59 pm

..oO(Cord-Heinrich Pahlmann)

>I need the HTML content of an extern webpage.
>Normally I just use file(http://externpage); to read the contents.
>But with file(httpS://externpage); i get an error.


What error?

>The script is running under http://, so that is probably the problem
>since http can't send to https (right?).


According to

HTTP and HTTPS
http://www.php.net/manual/en/wrappers.http.php

PHP needs OpenSSL support compiled-in to access HTTPS resources.

Micha
Cord-Heinrich Pahlmann

2007-01-28, 9:59 pm



On 28 Jan., 22:26, Joachim M=E6land <jm-n...@profine.net> wrote:
> On Sun, 28 Jan 2007 12:20:25 -0800, Cord-Heinrich Pahlmann wrote:
>
> What OS and webserver is the remote site running?


I have no clue.

>
> What OS, PHP version and webserver is your local site running?


I have a xampp test enviroment (Apache w/ PHP 4.4.4).
I'm sorry, but when I uploaded the script to my webhoster it worked.
So it might be an issue with the OpenSSL support as Micha suggested.
I just looked at the phpinfo() pages of both configs and on both=20
systems is openSSL enabled. My hoster has an older version, though.=20
But that shouldn't be the problem.


The error I get from my localhost is the following:
Warning: file(https://SITE) [function.file]: failed to open stream:=20
Invalid argument in ... on line...
It works fine with normal HTTP.

Since, the script is running on my webspaces I'm fine. But I still=20
would really like to know why it isn't working from localhost.

lorento

2007-01-29, 3:59 am

1=2E Check your firewall.
2=2E Check your internet connection wether use proxy or not to access=20
internet.
--
http://www.mastervb.net
On Jan 29, 5:34 am, "Cord-Heinrich Pahlmann" <S...@Heineken2000.de>=20
wrote:
> On 28 Jan., 22:26, Joachim M=E6land <jm-n...@profine.net> wrote:
>
..=2E?[color=darkred]
>
>
>
>
xampp test enviroment (Apache w/ PHP 4.4.4).[color=darkred]
> I'm sorry, but when I uploaded the script to my webhoster it worked.
> So it might be an issue with the OpenSSL support as Micha suggested.
> I just looked at the phpinfo() pages of both configs and on both
> systems is openSSL enabled. My hoster has an older version, though.
> But that shouldn't be the problem.
>
> The error I get from my localhost is the following:
> Warning: file(https://SITE) [function.file]: failed to open stream:
> Invalid argument in ... on line...
> It works fine with normal HTTP.
>
> Since, the script is running on my webspaces I'm fine. But I still
> would really like to know why it isn't working from localhost.


Joachim Mæland

2007-01-29, 7:58 am

On Sun, 28 Jan 2007 14:34:09 -0800, Cord-Heinrich Pahlmann wrote:

> On 28 Jan., 22:26, Joachim Mæland <jm-n...@profine.net> wrote:
>
> I have no clue.


Buggy IIS and line endings from a MAC are easy to overcome, but obviously
not what's giving you problems. Never mind the question.

> I have a xampp test enviroment (Apache w/ PHP 4.4.4). I'm sorry, but
> when I uploaded the script to my webhoster it worked. So it might be an
> issue with the OpenSSL support as Micha suggested. I just looked at the
> phpinfo() pages of both configs and on both systems is openSSL enabled.
> My hoster has an older version, though. But that shouldn't be the
> problem.


Micha said it all...
http://bugs.php.net/bug.php?id=28234
http://bugs.php.net/bug.php?id=38798

<guesswork>
I think the SSL entry you are looking for is an "ssl" entry under
"Registered Stream Socket Transports" in the phpinfo() page. And probably
an "https" entry under "Registered PHP Streams".
</guesswork>

> The error I get from my localhost is the following: Warning:
> file(https://SITE) [function.file]: failed to open stream: Invalid
> argument in ... on line...
> It works fine with normal HTTP.
>
> Since, the script is running on my webspaces I'm fine. But I still would
> really like to know why it isn't working from localhost.


Your PHP installation is probably broken from the maintainer. Try an
upgrade, your distro's own PHP package or build PHP yourself, using bits
and bytes... ;-)

--
Regards/mvh Joachim Mæland

If everything seems under control, you're just not going fast enough.
-Mario Andretti.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com