socket over ssl

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chifi
Forum Newbie
Posts: 4
Joined: Thu Nov 21, 2002 2:33 pm
Contact:

socket over ssl

Post by chifi »

any idea how I can open a socket over the ssl???

I need to send an xml fille to an https://www.example.com/etc/etc and the server will only accept a socket over ssl....

(just so you know I am trying to create a shopping cart application that makes use of th UPS online tools)...



Thank you,
Cip
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

saidwords
Forum Newbie
Posts: 3
Joined: Wed Oct 06, 2004 4:57 pm
Location: Palo-Alto

socket over ssl example script

Post by saidwords »

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Here is an example script that works for me:
* this example only gets a page from the server, it does not POST a page to the server. but it shouldnt be difficult to modify it to do so.

Code: Select all

$fp = fsockopen ("ssl://192.168.0.28", 443, $errno, $errstr, 30 );

if (!$fp) {
    echo "<br>ERROR: $errstr ($errno)";

} else {

    $request = "GET / HTTP/1.0\r\n";
    $request .= "Host: 192.168.0.28\r\n";
    $request .= "Connection: Close\r\n\r\n";
    fputs ($fp, $request);
    print "waiting for response...\n";
    while (!feof($fp)) {
        $result = fgets($fp,1024);
        print "$result\n";
    }
    fclose($fp);
}

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Please take note that this thread is almost 2 years old. :)
Post Reply