I am working on the same problem myself. Here's what I've tried so far - none of them have worked yet:
- The standard HTTP POST does not seem to work. However, I do receive an XML response which is more than I receive from the other 2 methods. The post looks something like this:
<FORM action="https://www.ups.com/ups.app/xml/Rate" method="post" enctype="application/x-www-form-urlencoded">
<INPUT type="HIDDEN" name="xml" value="<?xml version='1.0'?><AccessRequest xml:lang='eng-US'><AccessLicense..... etc. (basically the whole XML file here)
And then a submit button to post the form. This does not work. And for those who read the above and notice something, the data IS NOT URL encoded, I know. But it does not work either way. I use the PHP function $xml = url_encode($xml) to URL encode the data.
The second method I tried was to use fsocketopen() commands to send the HTTP data directly to the UPS server. Unfortunately, this does not seem to work either because they require an SSL connection on port 443, and when I run the following code nothing happens:
$host = "www.ups.com";
$method = "POST";
$path = "/ups.app/xml/Rate";
$data = $xml_urlencoded;
$fp = fsockopen($host,443);
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
echo $buf;
I believe it's because of the port 443 issue. If I run the same code above on port 80 I get some kind of response but of course it's not what I am looking for as it needs to be on the secure port.
The 3rd method I tried involved using cURL() in PHP, and of course the server I am using does not have the cURL implementation compiled in the PHP running on the server. Well, that's going to be another story to get that running.
So, as for now, I am looking into other solutions and have also been in communication with UPS's e-commerce people to assist in any advice they might offer.
If anyone has any ideas, please feel free to post here and it would be greatly appreciated.
Dennis McEntire