I\'m attempting to pull an XML page from the U.S. Postal Service (USPS) rate calculator, using PHP. Here is the code I am using (with my API login and password replaced of
One thing is that you need to URL encode the XML that you are sending to the service. The browser will do that for you automatically, but file_get_contents
won't.
Try this:
$param = urlencode("".
"FIRST CLASS PARCEL ".
"12345 54321 ".
"0 9 REGULAR ");
$api = "http://production.shippingapis.com/ShippingAPI.dll?API=RateV4&XML="
.$param;
... then the rest of the code
If that doesn't help, make sure you have error reporting activated so you get a response if file_get_contents
has an error.