私が使用している機能は次のとおりです。
function http_post ($url, $data)
{
$data_url = http_build_query ($data);
$data_len = strlen ($data_url);
date_default_timezone_set('America/New_York');
return array ('content'=>file_get_contents ($url, false
, stream_context_create (array ('http'=>array (
'method'=>'GET',
'header'=>"Connection: close\r\nContent-Length: $data_len\r\nContent-type: application/x-www-form-urlencoded\r\n",
'content'=>$data_url
)))),
'headers'=>$http_response_header
);
}
そして、呼び出しは次のとおりです。
http_post('http://www.wunderground.com/cgi-bin/findweather/getForecast/', array('airportorwmo'=>'query','historytype'=>'DailyHistory','backurl'=>"/history/index.html",'code'=>"$myCode",'month'=>"$myMonth",'day'=>"$myDay",'year'=>"$myYear"));
元のフォームは次のページにありますが、呼び出しではフォームのアクション ページを使用しています。
wunderground.com/history/
最終的には、リダイレクトされたページからコンテンツを取得したいと考えています。たとえば、次のようになります。
http://www.wunderground.com/history/airport/CWTA/2013/1/24/DailyHistory.html?req_city=McTavish&req_state=QC&req_statename=Quebec&MR=1
ただし、上記のように、フォームはさまざまな要素、つまりコード、月、日、年を取ります。