andyhewitson Posted February 29, 2004 Posted February 29, 2004 Hi I've scoured the contribs and forum for anything that uses the USPS address verification webtools service. Ensuring the validity of a destination address has got to be high up the on the agenda of priorities - shipping to an incorrect address costs in postal fees, support effort, and devalues quality of service. I'm setting up osCommerce for a real business, and postal address verification is a non-negotiable requirement. I'd rather not have to write it. If anyone knows of a module that performs USPS address verification, or perhaps uses another address verification service, please let me know. Thanks in advance
magicproshop Posted February 29, 2004 Posted February 29, 2004 Most Postal software programs will verfy and validate shipping addresses. Dazzle by Endicia http://endicia.com/ is what we us and it works very well. Hope that helps. Take care Arizona Patent Services
tonymazz Posted March 15, 2004 Posted March 15, 2004 How are you (if you are) linking into the osCommerce database? I am trying to do an import into Dazzle, but not having any luck. Tony Mazz
kingbono Posted August 5, 2004 Posted August 5, 2004 UPS told me that offer that tool and will help me integrate when we are ready.
goldencrown Posted February 15, 2005 Posted February 15, 2005 Hi I've scoured the contribs and forum for anything that uses the USPS address verification webtools service. Ensuring the validity of a destination address has got to be high up the on the agenda of priorities - shipping to an incorrect address costs in postal fees, support effort, and devalues quality of service. I'm setting up osCommerce for a real business, and postal address verification is a non-negotiable requirement. I'd rather not have to write it. If anyone knows of a module that performs USPS address verification, or perhaps uses another address verification service, please let me know. Thanks in advance <{POST_SNAPBACK}> here is some code that may help.done by a guy named tim.. <? // Initialize the returned USPS address $usps_address = array(); // These functions handle the XML tags // use this to keep track of which tag the parser is currently processing $currentTag = ""; function startElement($parser, $name, $attrs) { global $currentTag; $currentTag = $name; } function endElement($parser, $name) { global $currentTag; // clear current tag variable $currentTag = ""; } // process data between tags function characterData($parser, $data) { global $currentTag; global $usps_address; switch ($currentTag) { case "Address1": $usps_address['address1'] = $data; break; case "Address2": $usps_address['address2'] = $data; break; case "City": $usps_address['city'] = $data; break; case "State": $usps_address['state'] = $data; break; case "Zip5": $usps_address['zip5'] = $data; break; case "Zip4": $usps_address['zip4'] = $data; break; case "Description": $usps_address['error'] = $data; break; default: break; } } // Open a socket connection the USPS site // Change production to testing for, you know, testing purposes $fp = @fsockopen("production.shippingapis.com", 80, &$errno, &$errstr, 300); // If the connection is successful then set up the variables for the URL if($fp) { $address1 = rawurlencode($HTTP_POST_VARS["address2"]); $address2 = rawurlencode($HTTP_POST_VARS["address1"]); $city = rawurlencode($HTTP_POST_VARS["city"]); $state = $HTTP_POST_VARS["state"]; $zip = rawurlencode($HTTP_POST_VARS["zip"]); // Testing URL /*$url = "http://testing.shippingapis.com/ShippingAPITest.dll?API=Verify&XML=<AddressValidateRequest%20USERID=\"*********\"%20PASSWORD=\"*********\"><Address%20ID=\"3\"><Address1>" . $address1 . "</Address1><Address2>" . $address2 . "</Address2><City>" . $city . "</City><State>" . $state . "</State><Zip5>" . $zip . "</Zip5><Zip4></Zip4></Address></AddressValidateRequest>";*/ // Production URL $url = "http://production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=<AddressValidateRequest%20USERID=\"*********\"%20PASSWORD=\"**********\"><Address%20ID=\"0\"><Address1>" . $address1 . "</Address1><Address2>" . $address2 . "</Address2><City>" . $city . "</City><State>" . $state . "</State><Zip5>" . $zip . "</Zip5><Zip4></Zip4></Address></AddressValidateRequest>"; // Get the URL fputs($fp, "GET " . $url . " HTTP/1.0\n\n"); while(!feof($fp)) { $result = fgets($fp,500); $body .= $result; } // cut out the header $body = substr($body, strpos($body, "<?xml")); // initialize parser $xml_parser = xml_parser_create(); // set callback functions xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE); // parse the xml xml_parse($xml_parser, $body, feof($fp)); // clean up xml_parser_free($xml_parser); // handle any erros from USPS if(isset($usps_address["error"])) if ($usps_address["error"] == "That State is not valid.") $errors["state"] = "USPS error - State is not valid"; elseif ($usps_address["error"] == "That is not a valid city.") $errors["city"] = "USPS error - City is not valid"; else $errors["address1"] = "That address could not be found"; // If an address is returned then put it into the formvars like I want it. elseif(isset($usps_address["address1"]) ?? isset($usps_address["address2"])) { foreach ($usps_address as $key => $value) $usps_address[$key] = ucwords(strtolower($value)); $formvars["address1"] = $usps_address["address2"]; $formvars["address2"] = $usps_address["address1"]; $formvars["city"] = $usps_address["city"]; $formvars["state"] = strtoupper($usps_address["state"]); $formvars["zip"] = $usps_address["zip5"] . "-" . $usps_address["zip4"]; } } ?> Biscochitos almost as good as grandma
Recommended Posts
Archived
This topic is now archived and is closed to further replies.