fsocket_connect Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • blaine@worldweb.com

    fsocket_connect Help

    I'm trying to read the page

    but having little luck. as it seems like the connect returns Success
    (0) instead of letting me read the page...

    Any ideas?


    $host = "mpl-rdp-irm.mtn-park-lodges.com";
    $port = 443;
    $path = "/irm/default.asp";

    //you will need to setup an array of fields to post with
    //then create the post string
    $formdata["IRMPath"] = "\\\\mplLobstic k\rdpnt\rdp\"";
    $formdata["IRMResort"] = "02";
    //build the post string
    foreach($formda ta AS $key => $val){
    $poststring .= urlencode($key) . "=" . urlencode($val) . "&";
    }
    // strip off trailing ampersand
    $poststring = substr($poststr ing, 0, -1);

    $fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30);

    if(!$fp){
    //error tell us
    echo "$errstr ($errno)\n";
    echo "\nThis is printing success $fp ";

    }else{

    //send the server request
    fputs($fp, "POST $path HTTP/1.1\r\n");
    fputs($fp, "Host: $host\r\n");
    fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n" );
    fputs($fp, "Content-length: ".strlen($posts tring)."\r\n");
    fputs($fp, "Connection : close\r\n\r\n") ;
    fputs($fp, $poststring . "\r\n\r\n") ;

    //loop through the response from the server
    while(!feof($fp )) {
    echo "<BR>line: " . fgets($fp, 4096);
    }
    //close fp - we are done with it
    fclose($fp);


    }

  • Manuel Lemos

    #2
    Re: fsocket_connect Help

    Hello,

    on 08/29/2005 07:07 PM blaine@worldweb .com said the following:[color=blue]
    > I'm trying to read the page
    > https://mpl-rdp-irm.mtn-park-lodges....\&IRMResort=02
    > but having little luck. as it seems like the connect returns Success
    > (0) instead of letting me read the page...
    >
    > Any ideas?[/color]

    AFAIK, success is not 0 . Probably you do not have SSL support enabled.

    Anyway, you may also want to try this HTTP client class that supports
    SSL either with fsockopen or curl, depending on which is available. If
    it fails, it returns an explanatory error message.




    --

    Regards,
    Manuel Lemos

    PHP Classes - Free ready to use OOP components written in PHP
    Free PHP Classes and Objects 2026 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


    PHP Reviews - Reviews of PHP books and other products


    Metastorage - Data object relational mapping layer generator

    Comment

    Working...