Hi.
I need to POST data to a secure ([url]https://[/url]) server from another webserver.
So far I know that [url]https://[/url] defaults to port 443. I have this code:
<?PHP
// Prepare header
$header = "POST http_s://www_.google.com/adsense HTTP/1.0\r\n";
$header .= "Host: www_.google.com\r\n";
$header .= "Content-Length: 0\r\n";
$header .= "\r\n";
//Post back to PayPal validate
$fp = fsockopen ("www.google.com", 443, $errno, $errstr, 5);
echo "Connection Result: $errno, $errstr<p>";
if (!$fp) {
// HTTP ERROR
echo "Error: $errno, $errstr";
} else {
fputs ($fp, $header);
$res = "";
while (!feof($fp)) {
$res .= fgets ($fp, 1024);
}
}
echo $res;
?>
When I change the port to 80, it connects, but it sends back data saying that the page has been moved (to https://www.google.com/adsense).
I looked at what a 'normal' browser does in a packet sniffer, but I didnt get a lot out of it. I assume the browser takes part in securing the data, i.e. encryption?
All I need to do is send a single variable to a server, and read the responce.
Please advise.
Thank you!
K.
[EDIT]
Ignore the underscores in the header section, that just stops HTML link code being displayed.