Thursday 15 January 2015

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



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

i attempting query notam database (https://www.notams.faa.gov) in order have server parse notams display on map, code php.

i'm using curl send post data, however, server returning "invalid request". here post info i'm sending server. sent during request homepage (discovered using fiddler). notams needed "rkrr" icao (airport code incheon center here in korea).

what 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, 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 help!

seems have typo in variable $data value

$data = 'retrievelocid=rkrr&reporttype=raw&submit=view+notamss&actiontype=notamretriealbyicaos';

its

$data = 'retrievelocid=rkrr&reporttype=raw&actiontype=notamretrievalbyicaos&submit=view+notamss';

its not notamretriealbyicaos

its notamretrievalbyicaos

give try

php curl

No comments:

Post a Comment