The method did not return the full response object, the list of attendees was missing.

With this new version of the function, the attendees object is an array containing unnamed (just numbered) attendee-arrays.

The function only behaves differently on the attendee-object, the rest is left unchanged.

function bbb_api_parse_response($xml) {
$response = new StdClass;
if ($xml) {
foreach ($xml as $element => $node) {
if ($element == "attendees") {
$attendees = array();
$attendee_counter = 0;
foreach ($node as $attendee => $attendee_object) {
$attendees[$attendee_counter] = array();
foreach ($attendee_object as $attendee_element => $attendee_value) {
$attendees[$attendee_counter][(string)$attendee_element] = (string) $attendee_value;
}
$attendee_counter++;
}
$response->$element = $attendees;
} else {
$response->$element = (string) $node;
}
}
}
return $response;
}

Comments

srees’s picture

Issue summary: View changes

I'd suggest this is not the correct way to fix the parsing function, since it's specific to a particular API call and doesn't address the underlying issues.

Perhaps, try something like this:

function bbb_api_parse_response($xml) {
    $response = new StdClass;
    if ($xml) {
        foreach ($xml as $element => $node) {
            if(count($node->children()) > 0){
                $response->$element = bbb_api_parse_response($node);
            }else{
                $response->$element = $node->__toString();
            }
        }
    }
    return $response;
}