方法一:
-----------------------------------------------------------------
$ReqHeader ="POST $URI HTTP/1.1n"."Host: $Hostn".
"Content-Type: application/x-www-form-urlencodedn".
"Content-Length: $ContentLengthnn".
"$ReqBodyn";
// Open the connection to the host
$socket = fsockopen($Host, 80, &$errno, &$errstr);
if (!$socket){
$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
return $Result;
}
$idx = 0;
fputs($socket, $ReqHeader);
while (!feof($socket)){
$Result[$idx++] = fgets($socket, 128);
}
------------------------------------------------------
方法二:
------------------------------------------------------
$URL="www.mysite.com/test.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");
curl_exec ($ch);
curl_close ($ch);
------------------------------------------------------
沒有留言:
張貼留言