I’ve got my script worked out to grab information from the CIM:
$content =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
"<getCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
merchantAuthenticationBlock().
"<customerProfileId>$cid</customerProfileId>" .
"</getCustomerProfileRequest>";
$response = send_xml_request($content);
$parsedresponse = parse_api_response($response);
So how, now, do I write the returned value to a variable?
I’ve tried:
$customerPaymentProfileId = $parsedresponse->customerPaymentProfileId;
$customerShippingAddressId = $parsedresponse->customerShippingAddressId;
But this returns the variables empty. I feel like I’m missing something simple.
To see the structure of
$parsedresponsedo eitherprint_r($parsedresponse)orvar_dump($parsedresponse). From there you can see how the array is structured and get your values from there.FYI, the payment profiles are in an array so you will need to loop through them to get their values. Assuming
parsedresponseis the root XML node you can get them like this:FYI, this is a sample array structure for this response (From the AuthnetXML Sample Code. I am the author of this library):