donglei2022 2014-10-22 21:47
浏览 689
已采纳

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

I am attempting to query the NOTAM database (https://www.notams.faa.gov) in order to have the server parse the NOTAMs for display on a map, code is PHP.

I'm using cURL to send the POST data, however, the server is returning an "invalid request". Here is the POST data I'm sending to the server. It is exactly what is sent during a request from the homepage (discovered using Fiddler). The NOTAMs needed are the "RKRR" ICAO (airport code for Incheon Center here in Korea).

What am I missing here?

$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);

Thanks for the help!

  • 写回答

1条回答 默认 最新

  • drduinfu915094 2014-10-22 22:34
    关注

    Seems you have a typo in variable $data value

    $data = 'retrieveLocId=rkrr&reportType=Raw&submit=View+NOTAMSs&actionType=notamRetriealByICAOs';

    Its actually

    $data = 'retrieveLocId=rkrr&reportType=Raw&actionType=notamRetrievalByICAOs&submit=View+NOTAMSs';

    Its not notamRetriealByICAOs

    its notamRetrievalByICAOs

    Give a try

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 WSL上下载的joern在windows怎么用?
  • ¥17 MC9S12XS128单片机开发板实验
  • ¥15 jetson nano4GB
  • ¥15 电脑回复出厂设置,重装过程报错提示,求解决方案Windows 无法分析或处理无人参与应答文件 [C:\WINDOWS\Panther\unattend.xml,如何解决?
  • ¥15 进入lighttools中的UDOP编辑器的方法
  • ¥15 求Gen6d训练数据集
  • ¥20 liunx中winscp中可以登入ftp,但是不能登入sftp,如何解决
  • ¥15 lighttools的光学属性自定义的用法流程
  • ¥15 uni-app动态修改推荐页标题时报错
  • ¥15 图片是GET请求,后面是图片的id,Glide如何缓存?
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部