Open a https url on a special port ? (asp/ajax inside)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arnaud

    #1

    Open a https url on a special port ? (asp/ajax inside)

    Hi,

    I'm trying to translate an asp application in a php way, i'm using Php
    4.3.x.
    I'm going to try an asp newsgroup too, but as it mainly deals with Php, I
    would like to submit you my probem :

    I have to retrieve some XML datas from a server whose URL is built like that
    :


    I tried fopen, fsockopen with no result.

    So it's https, there is a port (4012 for example). Perhaps I forgot some
    particular https parameters with my fopen and fsockopen tries ?

    The original asp code is :
    ---
    Set myxml = Server.CreateOb ject("Msxml2.Se rverXMLHTTP.4.0 ")
    ' Opens the connection to the remote server :
    xml.Open "GET", url, False
    ---

    Php methods didn't work so I tried the ajax way :
    if(window.XMLHt tpRequest){
    // Firefox, Safari, Opera...
    req = new XMLHttpRequest( );
    } else if(window.Activ eXObject) {
    // Internet Explorer 5+
    req = new ActiveXObject(" Microsoft.XMLHT TP");
    } else {
    alert('Problem creating the XMLHttpRequest object');
    return false;
    }
    return req;

    .... But i'm not sure the ActiveXObject is identical to the original :
    Set myxml = Server.CreateOb ject("Msxml2.Se rverXMLHTTP.4.0 ")

    So if you have any ideas to do it with Php or any other technical ways, you
    are welcome.

    Thanks,
    Arnaud



  • Tim Van Wassenhove

    #2
    Re: Open a https url on a special port ? (asp/ajax inside)

    On 2006-03-17, Arnaud <no> wrote:[color=blue]
    > I'm trying to translate an asp application in a php way, i'm using Php
    > 4.3.x.[/color]

    [snip asp code]
    [color=blue]
    > So if you have any ideas to do it with Php or any other technical ways, you
    > are welcome.[/color]

    And where is the code that you've already tried but didn't work?

    --
    Met vriendelijke groeten,
    Tim Van Wassenhove <http://timvw.madoka.be >

    Comment

    • NC

      #3
      Re: Open a https url on a special port ? (asp/ajax inside)

      Arnaud wrote:[color=blue]
      >
      > I have to retrieve some XML datas from a server whose URL is built like that
      > :
      > https://myserver:4012/code/myapp?param1=3;
      >
      > I tried fopen, fsockopen with no result.[/color]

      What exactly did you try and what kind of "no result" have you achieved
      (error messages, etc.)?

      Also, have you tried cURL?

      Cheers,
      NC

      Comment

      • Arnaud

        #4
        Re: Open a https url on a special port ? (asp/ajax inside)


        "Tim Van Wassenhove" <timvw@users.so urceforge.net> a écrit dans le message
        de news: dvemlp$8fv$1@ik aria.belnet.be. ..[color=blue]
        > On 2006-03-17, Arnaud <no> wrote:
        > And where is the code that you've already tried but didn't work?[/color]

        Classical fsockopen or fopen :
        if ($handle = fopen($url_comp lete, "r"))
        echo 'ok';
        else
        echo 'ko';

        I also tried several syntax with the fsockopen (ssl://...) but i always
        obtain :
        Warning: fsockopen(): php_network_get addresses: getaddrinfo failed: Name or
        service not known (is your IPV6 configuration correct? If this error happens
        all the time, try reconfiguring PHP using --disable-ipv6 option to
        configure) in...

        Arnaud


        Comment

        • Arnaud

          #5
          Re: Open a https url on a special port ? (asp/ajax inside)


          "NC" <nc@iname.com > a écrit dans le message de news:
          1142613530.7092 11.49000@z34g20 00...legro ups.com...[color=blue]
          > What exactly did you try and what kind of "no result" have you achieved
          > (error messages, etc.)?[/color]

          if ($handle = fsockopen('http s://myserver:4012/code/param?', 80, $errno,
          $errstr))...
          or
          if ($handle = fsockopen('http s://myserver:4012/code/param?', 4012, $errno,
          $errstr))...
          or
          if ($handle = fsockopen('http s://myserver/code/param?', 4012, $errno,
          $errstr))...
          [color=blue]
          > Also, have you tried cURL?[/color]

          Not yet, but i'm looking at it, i can see in my phpinfo :
          CURL support enabled
          CURL Information libcurl/7.12.2 OpenSSL/0.9.7d zlib/1.1.4

          thanks,
          arnaud


          Comment

          • NC

            #6
            Re: Open a https url on a special port ? (asp/ajax inside)

            Arnaud wrote:[color=blue]
            > "NC" <nc@iname.com > a écrit dans le message de news:
            > 1142613530.7092 11.49000@z34g20 00...legro ups.com...
            >[color=green]
            > > What exactly did you try and what kind of "no result" have you achieved
            > > (error messages, etc.)?[/color]
            >
            > if ($handle = fsockopen('http s://myserver:4012/code/param?', 80, $errno,
            > $errstr))...
            > or
            > if ($handle = fsockopen('http s://myserver:4012/code/param?', 4012, $errno,
            > $errstr))...
            > or
            > if ($handle = fsockopen('http s://myserver/code/param?', 4012, $errno,
            > $errstr))...[/color]

            But of course it didn't work... Have you even looked at fsockopen()
            documentation? Check it out:

            Open Internet or Unix domain socket connection


            The correct usage of fsockopen() in your case would be something like
            this:

            $host = 'myserver';
            $port = 4012;
            $path = 'code/myapp?param1=3' ;
            $fp = fsockopen($host , $port, $errno, $errstr);
            if ($fp) {
            fputs($fp, "GET $path HTTP/1.0\r\n");
            fputs($fp, "Host: $host\r\n\r\n") ;
            } else {
            die ("Could not connect to $host on port $port: error $errno
            ($errstr)");
            }
            $data = '';
            while (!feof ($fp)) {
            $data .= fgets ($fp, 10240);
            }
            fclose ($fp);

            Now $data should contain the entire HTTP response, including HTTP
            headers...

            Cheers,
            NC

            Comment

            • Arnaud

              #7
              Re: Open a https url on a special port ? (asp/ajax inside)

              <"NC" <nc@iname.com > a écrit dans le message de news:
              1142619000.7117 12.38050@j33g20 00...legro ups.com...
              <But of course it didn't work... Have you even looked at fsockopen()
              <documentatio n? Check it out:
              <http://www.php.net/fsockopen
              <The correct usage of fsockopen() in your case would be something like
              <this:
              <$host = 'myserver';
              <$port = 4012;
              <$path = 'code/myapp?param1=3' ;
              <$fp = fsockopen($host , $port, $errno, $errstr);
              <[...]
              <Now $data should contain the entire HTTP response, including HTTP
              <headers...

              Hi,
              Yes, I tried that way too, but it didn't work either, the problem was a bad
              ip, it's resolved now.
              Thanks for your time and help.

              Arnaud


              Comment

              Working...