我需要将一些数据发布到我的服务器上的脚本。我正在使用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