I am using gabrielbull/ups-api for validating user address if a user provides an address I verify weather the address is correct or not I am using a got and getting a response which is quite difficult for me to access the data here is what I am getting in return
Ups\Entity\AddressValidationResponse Object
(
[response:protected] => SimpleXMLElement Object
(
[ValidAddressIndicator] => SimpleXMLElement Object
(
)
[AddressKeyFormat] => SimpleXMLElement Object
(
[AddressLine] => 2290 SW 128TH AVE
[Region] => MIRAMAR FL 33027-2648
[PoliticalDivision2] => MIRAMAR
[PoliticalDivision1] => FL
[PostcodePrimaryLow] => 33027
[PostcodeExtendedLow] => 2648
[CountryCode] => US
)
)
[requestAction:protected] => 1
)
This is the code I used
$address = new \Ups\Entity\Address();
$address->setAddressLine1('2290 SW 128th Street');
$address->setAddressLine2('');
$address->setStateProvinceCode('FL');
$address->setCity('Miramar');
$address->setCountryCode('US');
$address->setPostalCode('33027');
$eyaccessKey = 'key';
$userId = 'user id';
$password = 'password';
$xav = new \Ups\AddressValidation($accessKey, $userId, $password);
$xav->activateReturnObjectOnValidate(); //This is optional
try {
$response = $xav->validate($address);
echo "<pre>";
print_r($response);
echo "</pre>";
} catch (Exception $e) {
var_dump($e);
}
I tried to access the data by accessing the data using json object but I am unable to access there is what I tried to do
$response->response()->AddressKeyFormat
But I was unsuccessful I am not pretty much sure how do I access this data can anyone help me out hwo do validate address .