title: USPS API Address Validation Fail
body: <p>I'm trying to use the USPS API to validate an address. I've gone through the registration process, testing, and promotion to production.</p>
  
  <p>I'm using PHP and the simplexml_load_file function to make the call. When I make the call in PHP, USPS returns an error:</p>
  
  <pre><code>[Number] =&gt; 80040B1A
  [Description] =&gt; API Authorization failure. Verify is not a valid API name for this protocol.
  [Source] =&gt; USPSCOM::DoAuth
  </code></pre>
  
  <p>If I copy and paste the url passed to the simplexml_load_file function, I get a successful response:</p>
  
  <pre><code>&lt;AddressValidateResponse&gt;&lt;Address ID="0"&gt;&lt;Address2&gt;1228 E MAIN ST&lt;/Address2&gt;&lt;City&gt;MONTROSE&lt;/City&gt;&lt;State&gt;CO&lt;/State&gt;&lt;Zip5&gt;81401&lt;/Zip5&gt;&lt;Zip4&gt;5821&lt;/Zip4&gt;&lt;/Address&gt;&lt;/AddressValidateResponse&gt;
  </code></pre>
  
  <p>The url I'm using is (user ID changed):</p>
  
  <pre><code>http://production.shippingapis.com/ShippingAPI.dll?API=Verify&amp;XML=%3CAddressValidateRequest%20USERID=%123usrid456%27%3E%3CAddress%20ID=%270%27%3E%3CAddress1%3E1228%20East%20Main%20Street%3C/Address1%3E%3CAddress2%3E%3C/Address2%3E%3CCity%3EMontrose%3C/City%3E%3CState%3ECO%3C/State%3E%3CZip5%3E81401%3C/Zip5%3E%3CZip4%3E%3C/Zip4%3E%3C/Address%3E%3C/AddressValidateRequest%3E
  </code></pre>
  
  <p>I've called in to the 800 ICCC USPS number twice. The documentation is lacking in several respects, for instance, they say after registration the email will contain the url of the testing servers, but they aren't in the email. Also, having to call in for support and waiting on hold for almost an hour each time is frustrating. Ok, so enough complaining. Otherwise, USPS is awesome.</p>
  
  <p>I've read numerous posts, and tried what was suggested, but haven't been able to make the call in PHP work. Here's what I've tried:</p>
  
  <ul>
  <li>urlencode the XML string in the url submitted</li>
  <li>urlencode the entire url</li>
  <li>test and production servers</li>
  <li>curl instead of simplexml_load_file</li>
  <li>I've copied the url that works from the browser address bar and pasted it into the PHP code - and I still get the same error.</li>
  </ul>
  
  <p>I'm at a loss as what I should try next. Especially when I take the url passed to simplexml_load_file and copy/paste it into the browser address bar works properly.</p>
  
  <p>Here's a snippet I've tried:</p>
  
  <pre><code>$url = "http://production.shippingapis.com/ShippingAPI.dll?API=Verify&amp;XML=&lt;AddressValidateRequest%20USERID='123usrid456'&gt;&lt;Address ID='0'&gt;&lt;Address1&gt;&lt;/Address1&gt;&lt;Address2&gt;1228 East Main Street&lt;/Address2&gt;&lt;City&gt;Montrose&lt;/City&gt;&lt;State&gt;CO&lt;/State&gt;&lt;Zip5&gt;81401&lt;/Zip5&gt;&lt;Zip4&gt;&lt;/Zip4&gt;&lt;/Address&gt;&lt;/AddressValidateRequest&gt;";
  $addr_data = simplexml_load_file($url);
  </code></pre>
  
  <p><em>User ID changed</em> in the code above</p>
  
  <p>I'm sure I'm missing something obvious.</p>
  
  <p>Thanks in advance!</p>
  
  <p>Sloan</p>