I'm trying to integrate USPS Express mail delivery commitments into a shopping cart. (USPS Express Mail can be next day by noon, 3pm or two day, depending on the destination.)
Basically, I want to post a query to the USPS expressmailcommitments widget and then parse the data returned.
The form to do this is:
<form name="form1" method="post" action="http://webapps.usps.com/expressmailcommitments/commitments_results_w.jsp">
<input type="hidden" name="client_machine_date" value="11/26/08">
<input type="hidden" name="visited" value="1">
Origin ZIP Code
<input name="origin" type="text" value="" id="origin" maxlength="5" tabindex="1">
Destination ZIP Code
<input name="dest" id="dest" type="text" value="" maxlength="5" tabindex="3">
Shipping Date MM/DD/YY
<input name="ship" id="ship" type="text" value="11/26/08" maxlength="8" tabindex="4">
<input type="image" name="submit" src="http://webapps.usps.com/images/submit.gif" width="50" height="17" border="0" ALT="submit" tabindex="5">
</form>
The php code I'm using to test this is:
<?php
$url = "http://webapps.usps.com/expressmailcommitments/commitments_results_w.jsp";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CORLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "visited=1&client_machine_date=11/26/08&origin=90210&dest=90210&ship=11/26/08");
$result=curl_exec($ch);
curl_close($ch);
print $result;
?>
The problem I'm having is the initial response from the USPS app is a page "Searching for Commitments" which then redirects back to the USPS app. When it redirects, it attempts to access the app on my own website, which obviously doesn't work.
Is there some way to capture the results of the redirect?
Any help would be greatly appreciated!