Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7868571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:02:47+00:00 2026-06-03T01:02:47+00:00

I am trying to develop a USPS rate calculator for a cart that I

  • 0

I am trying to develop a USPS rate calculator for a cart that I am building in codeigniter. I am having issues getting getting success responses from the USPS test server and their api. I have called in with my issues and apparently, they don’t want to provide any support to anyone trying to create a custom solution. To make it more confusing, they told me that all I need to know can be found in their Development Guide v3.pdf, but in it they state:

Step 3: Run “Canned” Test from Test Server

Applicable APIs: All

The next step is to test your API interfaces. As a registered API user you have been granted access to the Shipping API test server. An important note: the test server is set up to only accept a subset of pre-defined XML transactions and return the pre-defined XML responses provided in this document.

If you have already successfully tested your API and have access to the production server, skip this step and proceed to Step 5: Run “Samples” from Production Server.

The problem here is that they do not provide any of the "subset of pre-defined XML transactions" as stated. They do provide test samples, but they seem to be designed for the production server which you only get access to whey you successfully test on the test server (in my script below, I have one of these samples which I tried unsuccessfully). I therefore refer to the USPS Rate Calculators v1-5-1.pdf where they give you specific test transaction samples. At best, I would get an error response stating:

<Error>
<Number>80040b1a</Number>
<Description>Authorization failure. You are not authorized to connect to this server.    </Description>
<Source>UspsCom:: DoAuth</Source>
</Error>

I know people have solved this, there are a few closed questions similar to this here, but none of them show a solution. My code follows:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Usps_curl extends CI_Controller {

    public function index()
    {
        
        $devurl = "testing.shippingapis.com/ShippingAPITest.dll";
        $puburl = "https://secure.shippingapis.com/ShippingAPITest.dll";
        
        $service = "RateV4";

//      ALTHOUGH THE USPS DEV GUIDE V3 SAYS 

//      $xml = '<RateV4Request USERID="225XXXXX5943">
//      <Revision>2</Revision>
//      <Package ID="1">
//          <Service>PRIORITY</Service>
//          <Container>FLAT RATE BOX</Container>
//          <ZipOrigination>20012</ZipOrigination>
//          <ZipDestination>20007</ZipDestination>
//          <Pounds>1</Pounds>
//          <Ounces>0.0</Ounces> 
//          <Size>REGULAR</Size> 
//      </Package>
//      </RateV4Request>';

//  THIS IS AN EXACT EXAMPLE PROVIDED IN THE USPS DEV GUIDE V3 - BUT I BELIEVE IT IS ONE OF THE FOUR "CANNED" TEST FOR THE PRODUCTION SERVER

//$xml = '<AddressValidateRequest USERID="225XXXXX5943">
//          <Address ID="0">
//              <Address1></Address1>
//              <Address2>6406 Ivy Lane</Address2>
//              <City>Greenbelt</City>
//              <State>MD</State>
//              <Zip5></Zip5>
//              <Zip4></Zip4>
//              </Address>
//          </AddressValidateRequest>';


//      THIS IS THE SAMPLE CODE FROM USPS RATE CALCULATORS V1-5-1 PDF

        $xml = rawurlencode('<RateV4Request USERID="225XXXXX5943">
        <Revision>2</Revision>
        <Package ID="1ST">
        <Service>FIRST CLASS</Service>
        <FirstClassMailType>LETTER</FirstClassMailType>
        <ZipOrigination>44106</ZipOrigination>
        <ZipDestination>20770</ZipDestination>
        <Pounds>0</Pounds>
        <Ounces>3.5</Ounces>
        <Container/>
        <Size>REGULAR</Size>
        <Machinable>true</Machinable>
        </Package>
        <Package ID="2ND">
        <Service>PRIORITY</Service>
        <ZipOrigination>44106</ZipOrigination>
        <ZipDestination>20770</ZipDestination>
        <Pounds>1</Pounds>
        <Ounces>8</Ounces>
        <Container>NONRECTANGULAR</Container>
        <Size>LARGE</Size>
        <Width>15</Width>
        <Length>30</Length>
        <Height>15</Height>
        <Girth>55</Girth>
        <Value>1000</Value>
        <SpecialServices>
        <SpecialService>1</SpecialService>
        </SpecialServices>
        </Package>
        <Package ID="3RD">
        <Service>ALL</Service>
        <ZipOrigination>90210</ZipOrigination>
        <ZipDestination>96698</ZipDestination>
        <Pounds>8</Pounds>
        <Ounces>32</Ounces>
        <Container/>
        <Size>REGULAR</Size>
        <Machinable>true</Machinable>
        <ShipDate>13-Dec-2010</ShipDate>
        </Package>
        </RateV4Request>');

        
        $request = $devurl . "?API=" . $service . "&xml=" . $xml;

//      echo "<pre>";
//      print_r($request);
//      die;
                
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $request);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_HTTPGET, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        
        
        
        $response = curl_exec($ch);
        curl_close($ch);
        
//      echo "<pre>";
//      print_r($response);
//      echo "</pre>";
        
    }
}

/* End of file usps_curl.php */
/* Location: ./application/controllers/usps_curl.php */

As you can see, I have the various strings commented and commented out. I have tried each of these with rawurlencode, urlencode & not encoded, but none work. Any help/suggestions would be greatly appreciated!

I know that I must be close, because I do at times get a proper error message, but I must be missing something here!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:02:48+00:00Added an answer on June 3, 2026 at 1:02 am

    That error response is just stating you aren’t auth’d for that API.

    I think you need to test using the test examples they provide. Once those are working, your API is working and you can get access to production API’s.

    curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER , false );
    curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST , false );
    

    will also be important in order to ignore cert errors (USPS does essentially the same thing in their example code–they set the ActiveX object to ignore cert errors).

    The PDF also says to use your browser if the client isn’t working. You can do this to see what you can expect to be returned.

    I just registered to test this… It seems at least one example is broken. But this example works in my browser:

    http://testing.shippingapis.com/ShippingAPITest.dll?API=CityStateLookup&XML=<CityStateLookupRequest USERID="xxxxxxx"><ZipCode ID= "0"><Zip5>90210</Zip5></ZipCode></CityStateLookupRequest> 
    

    (replace user id)

    <CityStateLookupResponse>
    <ZipCode ID="0">
    <Zip5>90210</Zip5>
    <City>BEVERLY HILLS</City>
    <State>CA</State>
    </ZipCode>
    </CityStateLookupResponse>
    

    Thing is with the examples: you have to use the appropriate testing server depending on whether or not it is an SSL API. Anything with an address in it is required to use SSL. So you have to meld the examples with the testing URL’s provided by USPS in the registration email.

    Anyway, so check out the URL above and get your code to match the output that you get in the browser. Once this works, tell them you’re LIVE and you will then get access to the production URL’s and price lookup API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to develop a BlackBerry application that will show data from an
While trying to develop my first VS Addin, I am having issues in firing
im trying to develop an app for a win CE mobile device that downloads
I'm trying to develop a class that supports an asynchronus method invocation. This is
I am trying to develop a game in Unity where you jump from 2D
Trying to develop using MVVM: I have this Csla.PropertyStatus control that is created in
I'm trying to develop a JS function that creates a new row each time
I'm trying to develop a firefox extension that inserts additional HTTP header fields into
I've been trying to develop a linq query that returns the ItemNumber column of
im trying to develop a social networking application and im having some trouble showing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.