dminder
Apr 9th, 2010, 08:15 AM
I found this code that I want to adapt for a project that I am working on and I cannot figure out where the issue is. I have end ; on each line, my single quotes all are good, and I only have one set of curly brackets...I need HELP!!
<?php
function validateAddress(){
$xmlstr = <<<XML
<AddressValidateRequest USERID="XXXXXXXXX">
<Address ID="0">
<Address1></Address1>
<Address2></Address2>
<City></City>
<State></State>
<Zip5></Zip5>
<Zip4></Zip4>
</Address>
</AddressValidateRequest>
XML;
$xml = new SimpleXMLElement($xmlstr);
$h = new http();
// Populate Address
$xml->Address->Address2 = 'MyAddress';
$xml->Address->Address1 = '';
$xml->Address->City = 'MyCity';
$xml->Address->State = 'MYState';
$xml->Address->Zip5 = 'MyZip';
// Prepare for XML call
$h->xmlrequest = $xml->asXML();
$output = str_replace(array("\n",'<?xml version="1.0"?>',"\t",),array('','',''), $xml->asXML());
$url = 'http://TESTING.ShippingAPIs.com/ShippingAPItest.dll?API=Verify&XML='.urlencode($output);
// Submit data and get results
$h->fetch($url,0,'','','','GET');
print_r($h->body); die();
// Put results into XML object
$xml = new SimpleXMLElement($h->body);
return $xml;
}
$xmlverify = validateAddress();
print_r($xmlverify);
?>
Thanks in advance!! :wave:
D
<?php
function validateAddress(){
$xmlstr = <<<XML
<AddressValidateRequest USERID="XXXXXXXXX">
<Address ID="0">
<Address1></Address1>
<Address2></Address2>
<City></City>
<State></State>
<Zip5></Zip5>
<Zip4></Zip4>
</Address>
</AddressValidateRequest>
XML;
$xml = new SimpleXMLElement($xmlstr);
$h = new http();
// Populate Address
$xml->Address->Address2 = 'MyAddress';
$xml->Address->Address1 = '';
$xml->Address->City = 'MyCity';
$xml->Address->State = 'MYState';
$xml->Address->Zip5 = 'MyZip';
// Prepare for XML call
$h->xmlrequest = $xml->asXML();
$output = str_replace(array("\n",'<?xml version="1.0"?>',"\t",),array('','',''), $xml->asXML());
$url = 'http://TESTING.ShippingAPIs.com/ShippingAPItest.dll?API=Verify&XML='.urlencode($output);
// Submit data and get results
$h->fetch($url,0,'','','','GET');
print_r($h->body); die();
// Put results into XML object
$xml = new SimpleXMLElement($h->body);
return $xml;
}
$xmlverify = validateAddress();
print_r($xmlverify);
?>
Thanks in advance!! :wave:
D