You can use the following functions to implement:
function Posttohost ($url, $data) {
$url = Parse_url ($url);
if (! $url) return "couldn ' t parse url";
if (!isset ($url [' Port ']) {$url [' port '] = "";}
if (!isset ($url [' query '])) {$url [' query '] = "";}
$encoded = "";
while (list ($k, $v) = each ($data)) {
$encoded. = ($encoded? "&": "");
$encoded. = Rawurlencode ($k). " = ". Rawurlencode ($v);
}
$fp = Fsockopen ($url [' Host '], $url [' Port ']? $url [' Port ']: 80);
if (! $fp) return "Failed to open socket to $url [host]";
Fputs ($FP, sprintf ("POST%s%s%s http/1.0\n", $url [' Path '], $url [' query ']? "?": "", $url [' query ']);
Fputs ($FP, "Host: $url [host]\n");
Fputs ($fp, "content-type:application/x-www-form-urlencoded\n");
Fputs ($FP, "Content-length:".) Strlen ($encoded). "\ n");
Fputs ($fp, "connection:close\n\n");
Fputs ($fp, "$encoded \ n");
$line = fgets ($fp, 1024);
if (!eregi ("^http/1\. ", $line)) return;
$results = ""; $inheader = 1;
while (!feof ($fp)) {
$line = fgets ($fp, 1024);
if ($inheader && ($line = = "\ n" | | $line = = "\ r \ n")) {
$inheader = 0;
}
ElseIf (! $inheader) {
$results. = $line;
}
}
Fclose ($FP);
return $results;
}
?>
--------------------------------------------------------------------------------------------------
You can do that.
$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);
?>
http://www.bkjia.com/PHPjc/317860.html www.bkjia.com true http://www.bkjia.com/PHPjc/317860.html techarticle You can use the following functions to implement: PHP Functionposttohost ($url, $data) {$url =parse_url ($url); if (! $url) return "couldn ' tparseurl"; Isset ($url [' Port ']) {$url [' Port ']= ';} if (!is ...