Post to ssl pages

Discussion in 'PHP' started by andrew47, Aug 16, 2007.

  1. #1
    Hello everyone,
    I need some help on some advanced level.
    I need to post some information to ssl page and read of the response.

    I know how to post to a regular (not encrypted) page using curl functions, but using this method for ssl pages does not return any responses from the remote server (although it seems like the post information is passing through).
    As far as i figured out i need to have openSSL installed and configured - which i do. So if someone could help me out with just some sample code of posting to https page would really appreciate it.
     
    andrew47, Aug 16, 2007 IP
  2. jazz7620

    jazz7620 Banned

    Messages:
    357
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have done it before. Can not find my code on this box though. Will look around for the code in the eve. Please send me a PM as reminder.
     
    jazz7620, Aug 16, 2007 IP
  3. bilal@revolutionhosting

    bilal@revolutionhosting Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    bilal@revolutionhosting, Aug 16, 2007 IP
  4. jazz7620

    jazz7620 Banned

    Messages:
    357
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok, I found the code...I am not using curl, I am using sockopen
    You can change it per your need.

    Here it is:

    $sock = fsockopen("ssl://select.worldpay.com",443);
    if(!$sock)
    {
    return "ERROR";
    }
    else
    {
    $sock = fsockopen("ssl://select.worldpay.com",443);
    fputs($sock, "POST /wcc/authorise HTTP/1.0\r\n");
    fputs($sock, "Host: www.YourWShost.com\r\n");
    fputs($sock, "Content-type: application/x-www-form-urlencoded\r\n");
    fputs($sock, "Content-length: " . strlen($data) . "\r\n");
    fputs($sock, "Accept: */*\r\n");
    fputs($sock, "\r\n");
    fputs($sock, "$data\r\n");
    fputs($sock, "\r\n");

    $tmp_headers = "";
    while ($str = trim(fgets($sock, 4096)))
    $tmp_headers .= $str."\n";

    $tmp_body = "";
    while (!feof($sock))
    $tmp_body .= fgets($sock, 4096);

    fclose($sock);
     
    jazz7620, Aug 16, 2007 IP
  5. supperman

    supperman Peon

    Messages:
    22
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    hello,curl absolutely is able to post ssl pages,as the php mannual refers to.I think the problem is what you get after you use curl.

    please var_dump() it.post here

    if there is no response,I think you didn't configure curl right.


    hope this helps.

    /s
     
    supperman, Aug 17, 2007 IP