I am integrating an airline ticket booking engine with a site. The booking engine provider has set up a search form that we can link to but I want to integrate the search form into our index page. In order to be able to submit to their results page I have to call their web service and get a 9 digit KeyWords access key to include in the $_POST data but this key expires virtually immediately so it can’t be generated when the index page loads, it has to be generated and appended to the $_POST data when the form is submitted. In order to accomplish this I have the form submit to a .php page on our server which queries the web service for the key, appends it to the $_POST data and then uses cURL to send it on to their ASP.NET results page. I am including the code of the .php page for your review. My question is 2 fold. The ASP.NET results page is redirecting me to a blank search form as if the proper key or fields weren’t included, but they are because when use cURL to send to a test page on my server I can output all the proper $_POST data. Is there some cross-domain issue that might cause this? Second, when cURL redirects, the url remains that of the .php page on my server rather than that of the server hosting the ASP.NET page and this causes problems with links to image files throughout the page. Is there a way with cURL to make the displayed url change too?
You can see the test work at http://laosparadisetravel.com/test/test1.php but it doesn’t work when submitted to the search engine providers page.
<?php
/*
Connect to the web service to get the KeyWords authorization string.
This 9 character string authroizes the submission of the form so must be added to $_POST variables coming from the original form.
Then the new set of $_POST variables are sent to the results page on the service provider's host server.
*/
$params->id="XXXXX";
$params->pwd="XXXXX";
$client = new SoapClient("http://www.bookingenginehost.com/IBEWS.ASMX?WSDL");
$result=$client->CheckAndGetKeyWords($params);
$KeyWords=$result->CheckAndGetKeyWordsResult;
$postData="";
while (list($key,$value) = each($_POST)){$postData .= $key . "=" . $value . "&";}
$len=strlen($postData);
$postData=substr($postData,0,($len-1));
$postData = "KeyWords=" . $KeyWords . "&" . $postData;
$Curl_Session = curl_init('http://laosparadisetravel. bookingenginehost.com/Page/Common/ExternalSearcher.aspx');
// this is the test page that shows that the proper $_POST data is being passed
//$Curl_Session = curl_init('http://www.laosparadisetravel.com/test/test3.php');
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, $postData);
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_exec ($Curl_Session);
curl_close ($Curl_Session);
?>