By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,729 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,729 IT Pros & Developers. It's quick & easy.

Reading a page with file() - Problems with https

P: n/a
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 <formdata from the
extern page.

Thx, for any suggestions.

Jan 28 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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.

Jan 28 '07 #2

P: n/a
..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
Jan 28 '07 #3

P: n/a


On 28 Jan., 22:26, Joachim MŠland <jm-n...@profine.netwrote:
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?
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
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.

Jan 28 '07 #4

P: n/a
1. Check your firewall.
2. Check your internet connection wether use proxy or not to access
internet.
--
http://www.mastervb.net
On Jan 29, 5:34 am, "Cord-Heinrich Pahlmann" <S...@Heineken2000.de
wrote:
On 28 Jan., 22:26, Joachim MŠland <jm-n...@profine.netwrote:
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?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
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.
Jan 29 '07 #5

P: n/a
On Sun, 28 Jan 2007 14:34:09 -0800, Cord-Heinrich Pahlmann wrote:
On 28 Jan., 22:26, Joachim M├Žland <jm-n...@profine.netwrote:
>>
What OS and webserver is the remote site running?

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.

Jan 29 '07 #6

P: n/a
This all below is my opinion, not any official post though...

1) have a debugging/error handling system. It is not so difficult to make, I
have made one myself and it really often helped us in development.

2) test code ALL the time, after every couple of lines, not in big chunks.

3) leave debugging features inside, even if you use simple lines like:
echo "now variable i = $i";
comment it, when you don't need it, but keep it there!

4) name varables in a way that even others understand them
$person['phone'] is good name , $p['p'] is bad.

5) put useful comments here and there. don't think commenting is waste of
time. avoid excessive egoboost comments, though.

Jan 29 '07 #7

P: n/a


On 29 Jan, 13:40, "P Pulkkinen"
<perttu.POISTATAMA.pulkki...@POISTATAMA.elisanet.f iwrote:
This all below is my opinion, not any official post though...

1) have a debugging/error handling system. It is not so difficult to make, I
have made one myself and it really often helped us in development.

2) test code ALL the time, after every couple of lines, not in big chunks.

3) leave debugging features inside, even if you use simple lines like:
echo "now variable i = $i";
comment it, when you don't need it, but keep it there!

4) name varables in a way that even others understand them
$person['phone'] is good name , $p['p'] is bad.

5) put useful comments here and there. don't think commenting is waste of
time. avoid excessive egoboost comments, though.
What has this got to do with the original subject?

Jan 29 '07 #8

P: n/a
"P Pulkkinen" <pe*************************@POISTATAMA.elisanet.f iwrote:
This all below is my opinion, not any official post though...

1) have a debugging/error handling system. It is not so difficult to make, I
have made one myself and it really often helped us in development.

2) test code ALL the time, after every couple of lines, not in big chunks.

3) leave debugging features inside, even if you use simple lines like:
echo "now variable i = $i";
comment it, when you don't need it, but keep it there!

4) name varables in a way that even others understand them
$person['phone'] is good name , $p['p'] is bad.

5) put useful comments here and there. don't think commenting is waste of
time. avoid excessive egoboost comments, though.
6) Libraries and most used chunk of code should be documented using
phpDocumentator or PHPLint (this latter is mine :-). Every programmer using
these tools should rely on the interface specified in the documentation,
and this documentation should be always available on-line via WEB.

7) Submit your program to a formal validator, as PHPLint.

8) Keep every project under a release version system like CVS. It is really
useful also when there is only one developer.

Best regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it

Jan 29 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.