PDA

View Full Version : USPS Labels and decoding base 64


donb
05-18-06, 07:04 PM
Well I finally have the usps api working. For those who might want the info in the future the correct syntax at the end of this message. Now does anyone know how to go about decoding a base 64 lable. The code I get back from usps looks a little like this. It can be either PDF of GIF depending on what I request.

......
</EMConfirmationNumber>
<EMLabel>
JVBERi0xLjINCjUgMCBvYmoNCjw8DQovVHlwZSAvWE9iamVjdA 0KL1N1YnR5cGUg\r\nL0ltYWdlDQovT
... more data
Ci9TaXplIDgNCi9Sb290IDEgMCBS\r\nDQo+Pg0Kc3RhcnR4cm VmDQo4OTAyOA0KJSVFT0YNCg==
</EMLabel>
</ExpressMailLabelCertifyResponse>


Here is the setup for calling the usps api.

<MvASSIGN NAME="url" VALUE ="{'http://testing.shippingapis.com/ShippingAPITest.dll?'}">
or
<MvASSIGN NAME="url" VALUE ="{'http://Production.ShippingAPIs.com/ShippingAPI.dll?'}">
<MvASSIGN NAME="API" VALUE ="{'ExpressMailLabelCertify'}">
<MvASSIGN NAME="XML" VALUE ="{'<ExpressMailLabelCertifyRequest USERID=\"xxxxxxx\" PASSWORD=\"xxxxxxx\">' $ Option_VAR $ .........$ ImageType_VAR $ '</ExpressMailLabelCertifyRequest>'}">
<MvCALL ACTION="{ url }" METHOD="GET" FIELDS="API,XML">
Process data (in my case I write it to a file for processing latter.
</MvCALL>

Thanks for the help.