Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created October 31, 2018 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/8b97e2c98600cc15ea514416ab6e96ae to your computer and use it in GitHub Desktop.
Save tommcfarlin/8b97e2c98600cc15ea514416ab6e96ae to your computer and use it in GitHub Desktop.
[PHP] Retrieving Namespaced Properties
<?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);
<?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