SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2000
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calculating Shipping From FedEx and USPS?

    I am in need of a way to get shipping costs. I am using PHP 4 on a server without PEAR's SOAP installed. I found a way to get UPS's rates by REST, but they don't come out entirely accurate. I have to multiple the cost by 1.25 to get it closer to the real cost.

    I need to get USPS and FedEx. They both have an API available. I checked FedEx's and it's a bit complicated. All example code I found was a few years old and didn't work or took several minutes to work. I checked FedEx.com for code, but all it has for PHP is PHP5 code which doesn't do me any good.

    I looked into other shopping carts, and found some have a table of rates, and then get the zone based on the zip codes. Once it knows the zone, it looks up the rate in the table. That seems like the easiest solution, but then I have to keep updating the table with new rates when FedEx changes them.

    I am leaning more towards screen scraping. That should work no matter what server I am on. I just have to make sure USPS and FedEx don't change their sites drastically where the script no longer finds the cost.

    Is there an easier way I am overlooking?

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you already check out the APIs for fedex, usps and ups?
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2000
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I checked FedEx's and it's a bit complicated. All example code I found was a few years old and didn't work or took several minutes to work. I checked FedEx.com for code, but all it has for PHP is PHP5 code which doesn't do me any good.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    With screen scraping, you run the risk of having your IP banned from the site and the thing breaking. That's why they provide an API. Is there a good reason you need to support PHP 4? PHP 5 is a good 5 years old now and well supported on most hosting environments.

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really, the best solution here is to spend the effort to understand the api's.

    Most php5 code can be modified to work for php4 if it doesn't already.

  6. #6
    SitePoint Enthusiast
    Join Date
    Sep 2000
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The host is kind of limited. Is there a way to use SOAP objects in PHP 4 without having to install any packages or plug-ins?

  7. #7
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sjaguar13 View Post
    The host is kind of limited. Is there a way to use SOAP objects in PHP 4 without having to install any packages or plug-ins?
    Read the documentation. We can't do it for you. If your unwilling to do the leg work there really isn't much we can do to help. It really isn't that complicated. You'll probably have to read for a few hours at most but that is understandable with documentation.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  8. #8
    SitePoint Enthusiast
    Join Date
    Sep 2000
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginethis View Post
    Read the documentation. We can't do it for you. If your unwilling to do the leg work there really isn't much we can do to help. It really isn't that complicated. You'll probably have to read for a few hours at most but that is understandable with documentation.
    Read what documentation? FedEx uses SOAP and that's all their documentation talks about. What good will that do me if I don't have access to the same PHP version? Or are you suggesting I read the PHP manual? In that case, you are the best one to be answering posts.

    If you took the time to actually read my post, you would have realized that I am actually looking for alternatives to the API, such as and including, but not limited to screen scraping and setting up a database table with zone and rates, and then just calculating what zone and address is in.

    Dan pointed out a huge problem with the screen scraping method. Crmalibu probably has the best solution, but I don't know if it's even possible. When looking up SOAP for PHP < 5, I get examples like Amazon's API, which REST is then recommended when SOAP can't be used. It's actually estimated that 85 percent of API users use REST over SOAP, and that REST is 6 times faster.

  9. #9
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can do SOAP with PHP4, sjaguar13.

  10. #10
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sjaguar13 View Post
    Read what documentation? FedEx uses SOAP and that's all their documentation talks about. What good will that do me if I don't have access to the same PHP version? Or are you suggesting I read the PHP manual? In that case, you are the best one to be answering posts.

    If you took the time to actually read my post, you would have realized that I am actually looking for alternatives to the API, such as and including, but not limited to screen scraping and setting up a database table with zone and rates, and then just calculating what zone and address is in.

    Dan pointed out a huge problem with the screen scraping method. Crmalibu probably has the best solution, but I don't know if it's even possible. When looking up SOAP for PHP < 5, I get examples like Amazon's API, which REST is then recommended when SOAP can't be used. It's actually estimated that 85 percent of API users use REST over SOAP, and that REST is 6 times faster.
    So I went to the fedex website, spent 5 mins looking around created a fake account and downloaded the PDF file that seems to be a pretty detailed outline of how to use there servers. While I was at it I downloaded the sample PHP5 code -- which you can port to PHP4 in the very least -- for kicks so I'm not exactly sure what you looked at but the information is there.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •