cURL请求:服务器接收POST数据,但返回无效请求


cURL Request: POST data is received by server, but returns invalid request

我正在尝试查询NOTAM数据库(https://www.notams.faa.gov)为了让服务器解析NOTAM以便在地图上显示,代码是PHP。

我使用cURL发送POST数据,但是,服务器返回了一个"无效请求"。这是我发送到服务器的POST数据。这正是在主页请求时发送的内容(使用Fiddler发现)。所需的NOTAM是"RKRR"ICAO(韩国仁川中心的机场代码)。

我在这里错过了什么?

$url = "https://www.notams.faa.gov/dinsQueryWeb/queryRetrievalMapAction.do";
$ch = curl_init($url);
$header = array('Host: www.notams.faa.gov', 'Content-Type: application/x-www-form-urlencoded',      'Connection: keep-alive', 'Cache-Control: max-age=0', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/*;q=0.8', 'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36', 'Referer: https://www.notams.faa.gov/dinsQueryWeb/', 'Accept-Encoding: gzip,deflate', 'Accept-Language: en-US,en;q=0.8', 'Origin: https://www.notams.faa.gov');
$data = 'retrieveLocId=rkrr&reportType=Raw&submit=View+NOTAMSs&actionType=notamRetriealByICAOs';
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);
echo $response;
curl_close($ch);

谢谢你的帮助!

变量$data值中似乎有拼写错误

$data='retrieveLocId=rkrr&reportType=原始&submit=查看+NOTAMS&actionType=notamRetriealByICAOs';

它实际上是

$data='retrieveLocId=rkrr&reportType=原始&actionType=notamRetrievalByICAO&submit=视图+NOTAMS';

它不是notamRetriealByICAOs

notamRetrievalByICAOs

尝试