UPS XML Rate PHP script
I did not think that this old php script is still interested by someone. Anyway, I received an inquiry today that my upsrate script’s result does not match with UPS homepage’s result.
Actually, they generate the same result if you provide the same option. Those options were not available to choose in the original upsrate script. I updated it today that you can try the script more easily.
- No trackbacks yet.









#1 by Ricardo at October 25th, 2007
Hi, you’ve saved me!!!!, this script will save me alot of work.
By the way I think you’ve got to check the Weigth field the legend seems to say that it’s for pounds,
but I think you actually send Kg, maybe you forgot to do the conversion from pounds to Kg when you did this
version of the script.
Anyway thanks a lot!!!!
#2 by Ricardo at October 25th, 2007
Hi, I’ve been customizing and testing your form, and I’ve found 2 miskates that have been driving me crazy
for a while, it’s to change the “Schipping To” adress. First you missed one equal symbol:
if($s_zip==” || $s_country==” || $t_zip==” || $t_country=” || $weight==”){
$error_msg=”please provide all information”;
“$t_country=”” you know you’re doing an asignation instead of a comparation.
You also misspelled the $t_country to check if it has been set.
You wrote
if ($t_coutnry == ” ) $t_country=’US’;
instead of
if ($t_country == ” ) $t_country=’US’;
I hope having halped you as you’ve helped me, and thanks again.
#3 by HanaDaddy at October 25th, 2007
Ricardo, Thank you for your feed back. I will update the tar file.
#4 by Jeff B at November 1st, 2007
I’m trying to get this to work with my web page. I tryied running it as is (execept for my passwords) at it seems to lock up after I submit the request for a price. I use godaddy lunix servers and I’m fairly sure that they have _curl enabled on all their lunix servers. Is their somthing else I need to change to make this work?
#5 by HanaDaddy at November 1st, 2007
You can test if curl module is compile in by using “phpinfo()” function. Please take a look at the PHP /Webserver log for any clue. Also you may want to test with console ‘curl’ command first.
#6 by Jeff B at November 1st, 2007
curl
CURL support enabled
CURL Information libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.2.3
The phpinfo() gave me the above info about CURL. So I guess that isn’t the problem. If I had the worng password or key would that cause the problem? That make you just through hoops a ups hand kive you developer keys/ developer user name, xml keys. If i’m using the wrong username or key would that cause it to hang? Thanks for any insite.
#7 by HanaDaddy at November 2nd, 2007
Test with console ‘curl’ command that if you can connect to the ups server.
> /usr/bin/curl -k https://www.ups.com/ups.app/xml/Rate
At least you can check if you can connect to the ups.com site from you hosting server.
#8 by Jeff B at November 5th, 2007
HanaDaddy, You script works great. My problem was the godaddy servers blocking any type of 3rd party web site (ie. UPS). godaddy wants me to upgrade to the dedicated or virtual dedicated servers for $50 dollars a month (haha). I switch servers to someone else and all is well! thanks.
#9 by Robert at April 11th, 2008
I must say that this script is a life saver in every possible way. I have gone thru so many over the last few months. The problem I ran into was my server does not handle asp. Just about every good working cal script out there is based on asp.
Again, thank you for your great work.
#10 by Robert at April 11th, 2008
Quick question. If possible, could you tell me how to add a quantity selection?
#11 by Fred at June 30th, 2008
Thanks for this wonderful class! Even though it may be “old” it still works a charm! Helped me quickly and easily estimate rate calculations into a project of mine.
Cheers!
#12 by smithveg at July 16th, 2008
Thank for sharing.
I’ve research on PHP + XML UPS Online Tools for whole day.
It seems this is the correct package that I really needs. Many Thanks.
#13 by nate at September 30th, 2008
this is absolutely great stuff. great work, i commend you! at first i could not get this to work and was about ready to give up but i looked through the .pdf document UPS provides for the rate and service selector. there is no php in that sdk but i did pick up on something interesting and decided to give it a try. i noticed the example url they say to to try for curl is: https://wwwcie.ups.com/ups.app/xml/Rate. in the code that is provided above, the url was identical except it was http://www.ups….. . once i changed it to wwcie then POOF! it worked! not sure why but i thought i would post this on here in case it is an issue for someone else.
#14 by HanaDaddy at September 30th, 2008
Thank you nate, but when I tried both www and wwwcie worked. Hmm…
#15 by nate at October 1st, 2008
i know i was more shocked than the next person that it worked. oh well! probably some configuration on our server or something. lucky break, i guess
#16 by Walter at November 10th, 2008
Right out of the box your software worked 1st time!! I have a web store that is written in perl and I was wondering how much of a hassle would it be to get you output into perl?
Thank you for making your program available to all.
Walter
#17 by Bob at November 13th, 2008
Is there a way to get the transit days for ground?
#18 by nate at January 19th, 2009
bob, i believe all ups ground shipments are guaranteed for 5 days but it is a very loose guarantee at that. if you wanted to use the 5 days as an expected transit time i think you’re going to have to make that calculation in php before it is outputted into html.
#19 by Bertster at April 7th, 2009
Awesome script saved me so much core scripting, 2009 and still as use full as 2007
#20 by Jameel Ahmed Ansari at June 9th, 2009
Thanks a lot
It is very helpful for php developer and easy way to integrate with UPS.
I searched a lot but find it better than other.
Thanks again