我需要將一些數據發佈到我的服務器上的腳本。我正在使用curl和冗長的錯誤報告。有誰知道爲什麼這不起作用嗎?如何排除故障 - 使用CURL將數據發佈到腳本
感謝,
發帖腳本
function makePost($postvars, $count) {
$url = 'http://servername.something.org/php/callback-f.php';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$result = curl_exec($ch);
curl_close($ch);
}
其發佈到腳本包含這一行:
<?php log_error("success",ERROR_LOG_TO_STDERR); ?>
我的POST變量一個字符串,它看起來像這樣:
surname=smth&address1=No+Value&this=that
的結果我得到的回覆是這樣的:
Connected to myserver.org port 80
> POST /php/callback-f.php HTTP/1.1
Host: myserver.org
Pragma: no-cache
Accept: */*
Content-Length: 1510
Content-Type: application/x-www-form-urlencoded
< HTTP/1.1 301 Moved Permanently
< Location: https://myserver/php/callback-f.php
< Content-Length: 0
< Date: Wed, 16 Nov 2011 16:21:23 GMT
< Server: lighttpd/1.4.28
* Connection #0 to host left intact
* Closing connection #0
看起來您的測試腳本只能通過https訪問,但您通過http發佈。 – liquorvicar