Reading a page with file() - Problems with https

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cord-Heinrich Pahlmann

    Reading a page with file() - Problems with https

    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.

  • =?iso-8859-1?q?Joachim_M=E6land?=

    #2
    Re: Reading a page with file() - Problems with https

    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.

    Comment

    • Michael Fesser

      #3
      Re: Reading a page with file() - Problems with https

      ..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


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

      Micha

      Comment

      • Cord-Heinrich Pahlmann

        #4
        Re: Reading a page with file() - Problems with https



        On 28 Jan., 22:26, Joachim Mæland <jm-n...@profine.ne twrote:
        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.

        Comment

        • lorento

          #5
          Re: Reading a page with file() - Problems with https

          1. Check your firewall.
          2. Check your internet connection wether use proxy or not to access
          internet.
          --

          On Jan 29, 5:34 am, "Cord-Heinrich Pahlmann" <S...@Heineken2 000.de
          wrote:
          On 28 Jan., 22:26, Joachim Mæland <jm-n...@profine.ne twrote:
          >
          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.

          Comment

          • =?iso-8859-1?q?Joachim_M=E6land?=

            #6
            Re: Reading a page with file() - Problems with https

            On Sun, 28 Jan 2007 14:34:09 -0800, Cord-Heinrich Pahlmann wrote:
            On 28 Jan., 22:26, Joachim Mæland <jm-n...@profine.ne twrote:
            >>
            >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...



            <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.

            Comment

            • P Pulkkinen

              #7
              HOW-TO: avoid coding problems and find errors

              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.



              Comment

              • Captain Paralytic

                #8
                Re: HOW-TO: avoid coding problems and find errors



                On 29 Jan, 13:40, "P Pulkkinen"
                <perttu.POISTAT AMA.pulkki...@P OISTATAMA.elisa net.fiwrote:
                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?

                Comment

                • Umberto Salsi

                  #9
                  Re: HOW-TO: avoid coding problems and find errors

                  "P Pulkkinen" <perttu.POISTAT AMA.pulkkinen@P OISTATAMA.elisa net.fiwrote:
                  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

                  Comment

                  Working...