stevil Posted June 9, 2008 Share Posted June 9, 2008 Hi All, I'm looking to post some variables using a PHP script rather than a form. I've done this before to a standard URL fine, but now I'm trying to do it to a HTTPS script. When doing this I get the error:- Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please. The code I'm using is:- $header .= "POST /api/transact.php \r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; //Sends Data To Server $fp = fsockopen ('domain.com', 443, $errno, $errstr, 30); fputs ($fp, $header . $req); //Checks For HTTP Error if (!$fp) { //Do Error Here print "HTTP ERROR"; } else { //Gets Data while (!feof($fp)) {$ReturnText .= fgets ($fp, 1024);} print $ReturnText."<br />\n"; } I think I could possibly do this with cUrl? I'd much rather do this with sockets though. Anyone have any idea of how to manage this? I'm sure it's something simple, but it's nothing I can find anywhere online unfortunatly. Stevil Link to comment https://forums.phpfreaks.com/topic/109482-solved-https-post-vars/ Share on other sites More sharing options...
stevil Posted June 10, 2008 Author Share Posted June 10, 2008 I figured it out =) you need to use ssl:// infront of the domain to make it secure. $fp = fsockopen ('ssl://domain.com', 443, $errno, $errstr, 30); After changing this it worked. You need to make sure your PHP version supports it though, I tried earlier on doing this smae thing, but didn't realise I was using a PHP which did not support this. Link to comment https://forums.phpfreaks.com/topic/109482-solved-https-post-vars/#findComment-561627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.