我想送與fsock, 後變數,但是當我嘗試這個辦法:fsock:找不到插座運輸「HTTP」
$post_arr = array ("a" => "b");
$addr = 'http://1.2.3.4/confirmation.html';
$fp = fsockopen($addr, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$req = '';
foreach ($post_arr as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&" . $key . "=" . $value;
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
fwrite($fp, $header);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
我得到「無法找到插座運輸‘HTTP’」 , 有什麼想法爲什麼?
這個小程序庫可以幫助你編寫更簡單的HTTP請求:https://github.com/jamm/HTTP – 2012-04-01 15:11:01
你應該省略'http://'部分,默認情況下'tcp:'transport是用過的。 – 2012-04-01 15:30:51