服务器是否真的收到了请求,并且您是否正确处理了主机名(别名)?
添加到我的 .hosts 文件后
检查您的网络服务器日志,看看请求是如何进来的......
curl 具有转储发送请求和接收响应的选项,称为跟踪,它将被保存到文件中。
- 痕迹
如果您缺少主机或标头信息 - 您可以使用配置选项强制这些标头。
我会让 curl 请求在命令行上运行,然后尝试在 PHP 中实现。
配置选项是
-K/--配置
curl 中相关的选项在这里
--trace 启用对给定输出文件的所有传入和传出数据(包括描述性信息)的完整跟踪转储。使用“-”作为文件名将输出发送到标准输出。
This option overrides previous uses of -v/--verbose or --trace-ascii.
If this option is used several times, the last one will be used.
-K/--config 指定从哪个配置文件读取 curl 参数。配置文件是一个文本文件,可以在其中写入命令行参数,然后将其用作实际命令行中的参数。选项及其参数必须在同一配置文件行中指定,由空格、冒号、等号或它们的任何组合分隔(但是,首选分隔符是等号)。如果参数要包含空格,则参数必须用引号引起来。在双引号内,可以使用以下转义序列:\、\"、\t、\n、\r 和 \v。忽略任何其他字母前面的反斜杠。如果配置行的第一列是“#”字符,该行的其余部分将被视为注释。
Specify the filename to -K/--config as '-' to make curl read the file from stdin.
Note that to be able to specify a URL in the config file, you need to specify it using the --url option, and not by simply writing the URL on its own line. So, it could look similar to this:
url = "http://curl.haxx.se/docs/"
Long option names can optionally be given in the config file without the initial double dashes.
When curl is invoked, it always (unless -q is used) checks for a default config file and uses it if found. The default config file is checked for in the following places in this order:
1) curl tries to find the "home dir": It first checks for the CURL_HOME and then the HOME environment variables. Failing that, it uses getpwuid() on UNIX-like systems (which returns the home dir
given the current user in your system). On Windows, it then checks for the APPDATA variable, or as a last resort the '%USERPROFILE%\Application Data'.
2) On windows, if there is no _curlrc file in the home dir, it checks for one in the same dir the curl executable is placed. On UNIX-like systems, it will simply try to load .curlrc from the deter-
mined home dir.
# --- Example file ---
# this is a comment
url = "curl.haxx.se"
output = "curlhere.html"
user-agent = "superagent/1.0"
# and fetch another URL too
url = "curl.haxx.se/docs/manpage.html"
-O
referer = "http://nowhereatall.com/"
# --- End of example file ---
This option can be used multiple times to load multiple config files.