我有一个 asp.net 页面:“ abc.aspx ”和一个 php 页面:“ def.php ”。我已经从def.php提交了一个表单,动作是abc.aspx,它重定向到包含我需要的结果的“ ghi.aspx ”。当我只有abc.aspx的 url时,如何获取 ghi.aspx 的内容。
这是我在 def.php 中的代码:
`
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
if($_POST["submit"])
{
$data= array(
'__VIEWSTATE'=>$_POST['vst'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$RadioButtonMarketStructure'=>$_POST['ticket_rndtrip'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$TextBoxMarketOrigin1'=>$_POST['start_point'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$TextBoxMarketDestination1'=>$_POST['end_point'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$TextboxDepartureDate1'=>$_POST['depart_day'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$TextboxDestinationDate1'=>$_POST['return_day'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListCurrency'=>$_POST['currency'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListPassengerType_ADT'=>$_POST['adult_content'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListPassengerType_CHD'=>$_POST['child_content'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListPassengerType_INFANT'=>$_POST['infant_content'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$RadioButtonSearchBy'=>$_POST['search_by'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$numberTrips'=>$_POST['trip_num'],
'ControlGroupSearchView$AvailabilitySearchInputSearchView$ButtonSubmit'=>$_POST['submit'],
);
$url = 'http://abc.aspx';//In my case, I think must be abc.aspx because it redirect to ghi.aspx after post.
var_dump(do_post_request($url, $data));
}
?>`
<html>
<head>
</head>
<body>
<form action="" method="post" id="SkySales">
<input id="viewState" type="hidden" value="/wEPDwUBMGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFJ01lbWJlckxvZ2luU2VhcmNoVmlldyRtZW1iZXJfUmVtZW1iZXJtZTxtWS/I2BXFBfalk96y3LBuGXXD" name="vst" xmlns:bookinginfo="urn:bcs:extensions:bookinginfo">
<input type="radio" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_RoundTrip" name="ticket_rndtrip" class="radioSingle" autofocus="" value="RoundTrip" checked=""><label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_RoundTrip">Return</label>
<input type="radio" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_OneWay" name="ticket_rndtrip" class="radioSingle" value="OneWay"><label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_OneWay">One Way</label>
<input type="radio" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_OpenJaw" name="ticket_rndtrip" class="radioMulti" value="OpenJaw"><label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_OpenJaw">MultiCity</label>
<input id="ControlGroupSearchView_AvailabilitySearchInputSearchView_TextBoxMarketOrigin1" name="start_point" class="text airport-select location-origin focus-clear" type="text" data-airport-code="" value="Ho Chi Minh City (SGN)" title="Origin" autocomplete="off" data-airportselect-id="1">
<input id="ControlGroupSearchView_AvailabilitySearchInputSearchView_TextBoxMarketDestination1" name="end_point" class="text airport-select location-destination focus-clear" type="text" data-airport-code="" title="Destination" value="Hanoi (HAN)" autocomplete="off" data-airportselect-id="2">
<label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_TextboxDepartureDate1" class="date" style="display: none; ">Departure</label>
<input type="text" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_TextboxDepartureDate1" autocomplete="off" name="depart_day" value="14/08/2012" class="text datepick-depart date-pick hasDatepicker" title="Departure" maxlength="10" data-date="1344877200000">
<label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_TextboxDestinationDate1" class="date" style="display: none; ">Return</label>
<input type="text" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_TextboxDestinationDate1" autocomplete="off" name="return_day" value="21/08/2012" class="text datepick-return date-pick hasDatepicker" title="Return" maxlength="10" data-date="1345482000000">
<label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListCurrency" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListCurrency_label" style="display:none;">Currency </label>
<select id="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListCurrency" name="currency">
<option value="VND" selected="selected">Vietnam Dong</option>
</select>
<label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_ADT">Adult</label>
<select id="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_ADT" name="adult_content" style="opacity: 1; " class="">
<option selected="" value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
</select>
<label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_CHD">Child<span>2-11</span></label>
<select id="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_CHD" name="child_content" style="opacity: 1; " class="">
<option selected="" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_INFANT">Infants<span><2</span></label>
<select id="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_INFANT" name="infant_content" style="opacity: 1; " class="">
<option selected="" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="radio" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_SearchStandard" name="search_by" value="SearchStandard" checked="checked">
<label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_SearchStandard" class="small">I need to travel on this date</label>
<input type="radio" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_SearchLFF" name="search_by" value="SearchLFF">
<label for="ControlGroupSearchView_AvailabilitySearchInputSearchView_SearchLFF" class="small">I just want the cheapest flight</label>
<input type="hidden" name="trip_num" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_numberTrips" value="2">
<input type="submit" id="ControlGroupSearchView_AvailabilitySearchInputSearchView_ButtonSubmit" name="submit" class="png-bg">
</form>
</body>
</html>