【发布时间】:2010-11-08 15:54:45
【问题描述】:
问候。
所以,我在 Amazon EC2 上运行 Fedora Core 8。我安装了 httpd、php5 和 libcurl,以及一堆其他的东西。似乎工作得很好,但后来我意识到我的 php 脚本中的 curl 没有发送 POST 数据。命令行中的相同请求仍然有效。我还在我的本地机器(Win XP)和另一台远程机器(Ubuntu)上运行了相同的 php 脚本,它们运行良好,正在发送 POST 数据,但在 FC8 上没有。它需要任何特殊配置吗?有防火墙问题吗?
这是 PHP 代码:
error_reporting(E_ALL);
$ch = curl_init("http://foller.me/tmp/postdump.php");
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "something=somewhere");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0);
$response = curl_exec($ch);
echo $response;
curl_close($ch);
下面是对应的 curl 命令:
curl -d "something=somethingelse" http://foller.me/tmp/postdump.php
我也在 apache error_log 中找到了相应的条目,这是我想出的:
* About to connect() to foller.me port 80 (#0)
* Trying 75.101.138.148... * connected
* Connected to foller.me (75.101.138.148) port 80 (#0)
> GET /tmp/postdump.php HTTP/1.1
Host: foller.me
Accept: */*
< HTTP/1.1 200 OK
< Date: Tue, 07 Jul 2009 10:32:18 GMT
< Server: Apache/2.2.9 (Fedora)
< X-Powered-By: PHP/5.2.6
< Content-Length: 31
< Connection: close
< Content-Type: text/html; charset=UTF-8
<
* Closing connection #0
没有发送 POST 数据,明白吗?有什么想法吗?
在此先感谢大家。 〜K。
【问题讨论】: