看板 PHP 關於我們 聯絡資訊
我想從AT&T的web TTS系統取得wav檔案, (對方的cgi會回應一個wav檔案) 這是錯誤訊息: HTTP/1.1 400 Bad Request Date: Wed, 11 Feb 2009 17:03:09 GMT Server: Apache/2.0.52 (CentOS) Content-Length: 326 Connection: close Content-Type: text/html; charset=iso-8859-1 Bad Request Your browser sent a request that this server could not understand. Apache/2.0.52 (CentOS) Server at 192.20.225.55/tts/cgi-bin/nph-talk Port 80 我修正程式了,紅字的部份 $fp = fsockopen("192.20.225.55" ,80, $errno, $errstr); if (!$fp){ echo "----->".$errstr."<-----"; die("$errstr ($errno)\n"); }else{ $data = "txt=".$_GET['txt']; $out="POST / HTTP/1.0\r\n"; $out.="Host: 192.20.225.55/tts/cgi-bin/nph-talk\r\n"; $out.="Content-type: application/x-www-post\r\n"; $out.="Content-length: " . strlen($data) . "\r\n"; $out.="Accept: */*\r\n"; $out.="\r\n".$data."\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.68.92.156
tka :會不會太硬, 這裡不能用 curl 嗎? 02/11 23:34
ybite :有出現任何錯誤訊息嗎? 02/12 00:07
buganini :fsockopen不用網址吧 給ip就好 網只是寫在POST後面 02/12 00:22
buganini :Host裡面要寫http:// 吧? 不確定 02/12 00:23
buganini :跟cgi什麼的完全沒有關係 還不都是HTTP 02/12 00:25
buganini :另外curl的確比較好用 02/12 00:27
buganini :fsockopen跟HTTP是不同層的東西 02/12 00:35
※ 編輯: costbook 來自: 203.68.92.156 (02/12 01:07)