Sending and processing an XML request - need advice

darkroast

Member
Hello all -

I'm working on a process which needs to be able to verify an address (US only) via the US Postal Service API, which uses an XML request and response, then update the appropriate fields in the form. Ideally, I'd like to have the user enter the address information, then click a button which will send the request; when the response is received, the system will process the XML response, and update the fields.

Here's an example of the request:
http://production.shippingapis.com/...PI=Verify&XML=<AddressValidateRequest USERID="xxxxxxxxxxxx">
<Address>
<Address1></Address1>
<Address2>6406 Ivy Lane</Address2>
<City>Greenbelt</City>
<State>MD</State>
<Zip5></Zip5>
<Zip4></Zip4>
</Address>
</AddressValidateRequest>

and the response it brings back (assuming the address is valid):
<?xml version="1.0"?>
<AddressValidateResponse>
<Address ID="0">
<Address2>6406 IVY LN</Address2>
<City>GREENBELT</City>
<State>MD</State>
<Zip5>20770</Zip5>
<Zip4>1440</Zip4>
</Address>
</AddressValidateResponse>

I assume this could be done using PHP, but I'm not as familiar as I'd like to be with XML requests / responses. If I used PHP, I know how to use the placeholders to insert the address info into the request. But I'd appreciate any advice on how to create and send the request, and process the response, using Fabrik.

Possibly, if I get this working, I'll put together a plugin of some sort so that I can share this back with the community.
 
I've done something like this with a weather API and json format. Example
Code:
<?php
$json_string = file_get_contents("http://api.wunderground.com/api/Your_Key/geolookup/conditions/q/IA/Cedar_Rapids.json");
$parsed_json = json_decode($json_string);
$location = $parsed_json->location->city;
$temp_f = $parsed_json->current_observation->temp_f;
echo "Current temperature in $location is: $temp_f \n";
?>

Doesn't your API provide any code example?
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top