-
-
Save tommcfarlin/8b97e2c98600cc15ea514416ab6e96ae to your computer and use it in GitHub Desktop.
[PHP] Retrieving Namespaced Properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Setup the XML to connect to the API endpoint. | |
$namespaceExampleGetIDs = [ | |
'Version' => $this->version, | |
'ApiKey' => $this->getPrivateKey(), | |
'acmePasscode' => $this->getPasscode(), | |
'Call' => [ | |
'_attributes' => ['Method' => 'Namesepace.Example.GetIDs'], | |
'Date' => $this->getTimestamp(), | |
], | |
]; | |
$xml = ArrayToXml::convert($namespaceExampleGetIDs, 'Acme', false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Now make a request to the server. | |
$response = $this->makePostRequest($xml); | |
$xmlResponse = new SimpleXMLElement($response->getBody()->getContents()); | |
// Iterate through all of the event IDs to get the information about them. | |
$events = []; | |
foreach ($xmlResponse->{'Namesepace.Example.GetIDs'}->EventID as $eventId) { | |
// Work with the $eventId however necessary... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment