Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin tommcfarlin/00-request.php Secret
Created Oct 31, 2018

Embed
What would you like to do?
[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
You can’t perform that action at this time.