|
Posted by glumtail on 08/06/05 12:34
you can try this:
$sock = fsockopen($parse_url['host'], $parse_url['port'], $errno, $errstr, 30);
if (!$sock) {
die("$errstr ($errno)\r\n");
}
$tmp = explode('&',$parse_url['query']);
$data = NULL;
foreach($tmp as $val) {
$p = explode('=',$val);
if(empty($data)) {
$data = $p[0] . "=" . urlencode($p[1]);
} else {
$data .= "&" . $p[0] . "=" . urlencode($p[1]);
}
}
fwrite($sock, "POST " . $parse_url['path'] . " HTTP/1.0\r\n");
fwrite($sock, "Host: " . $parse_url['host'] . "\r\n");
fwrite($sock, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($sock, "Content-length: " . strlen($data) . "\r\n");
fwrite($sock, "Accept: */*\r\n");
fwrite($sock, "\r\n");
fwrite($sock, "$data\r\n");
fwrite($sock, "\r\n");
$body = "";
while (!feof($sock)) {
$body .= fgets($sock, 4096);
}
fclose($sock);
[Back to original message]
|