0
$bbb = new BigBlueButton();

$recordingsParams = array(
    'meetingId' => '', 

);

// Now get recordings info and display it:
$itsAllGood = true;
try {$result = $bbb->getRecordingsWithXmlResponseArray($recordingsParams);}
    catch (Exception $e) {
        echo 'Caught exception: ', $e->getMessage(), "\n";
        $itsAllGood = false;
    }

    if ($itsAllGood == true) {
        if ($result == null) {
            echo "Failed to get any response. Maybe we can't contact the BBB server.";
        }   
        else { 

         if ($result['returncode'] == 'SUCCESS') {
                echo "<p>Meeting info was found on the server.</p>";
            }


            else {
                echo "<p>Failed to get meeting info.</p>";
            }
            print_r($result);

        }
    }

When I am using Bigbluebutton, I need to retrieve the particular data from these XML format response. I don't know how to retrieve the particular data from these XML format?

Array
(
    [returncode] => SimpleXMLElement Object
        (
            [0] => SUCCESS
        )

    [0] => Array
        (
            [meetingId] => SimpleXMLElement Object
                (
                    [0] => newtech
                )                       
         )

    [1] => Array
        (
            [meetingId] => SimpleXMLElement Object
                (
                    [0] => menew
                )                          
        )  
)

I need to display the values of meetingId.

Ived
  • 111
  • 1
  • 1
  • 11
  • add your code in question – Chetan Ameta Feb 29 '16 at 10:05
  • 1
    Have you had a look at the [basic examples in the manual](http://www.php.net/manual/en/simplexml.examples-basic.php)? Do you have any PHP code you've tried so far, so we can help you understand where you've gone wrong? It would also be good to include the actual XML you're working with, rather than the `print_r` output (which can be a bit misleading with SimpleXML). – IMSoP Feb 29 '16 at 10:06
  • with SimpleXMLElement in place you can reach child values easily, echo $simplexml->meetingId; – Muhammed Feb 29 '16 at 10:13
  • I got this output when I print my result (print_r($result)). I don't know how to display the values of meetingId. – Ived Feb 29 '16 at 10:24
  • Hi Muhammed, when I try your code, I got the following error. Notice: Trying to get property of non-object – Ived Feb 29 '16 at 10:25
  • 2
    Rather than using `print_r`, I would recommend just echoing the raw XML structure (`echo $response->asXML()`). Then look at the examples in the manual, and see if you can relate them to the structure you have. – IMSoP Feb 29 '16 at 11:41

1 Answers1

0

If you'd rather work with arrays you can cast the XML as well. This function returns an array with info on what is going on on your server if called (improvements still very welcome):



    function getServerInfo() {
        $url="https://you-bbb-server-api-getMeetings-call-url";
        $a= (array)new SimpleXMLElement(file_get_contents($url));
        if($a["returncode"]=="SUCCESS") {
            if($a["meetings"]) {
               foreach($a["meetings"] as $meeting) {
                    $meeting=(array)$meeting;
                    $data["Meetings"][$meeting["meetingID"]]["Teilnehmer"]=$meeting["participantCount"];
                    $data["Meetings"][$meeting["meetingID"]]["Name"]=$meeting["meetingName"];
                    $data["Gesamt"]+=(int)$meeting["participantCount"];
                    $data["Anzahl"]++;
                    $data["Meetings"][$meeting["meetingID"]]["Video"]=$meeting["videoCount"];
                    $data["Meetings"][$meeting["meetingID"]]["Start"]=date('d.m.Y H:i:s',floor($meeting["startTime"]/1000));
                    if($meeting["attendees"]) foreach($meeting["attendees"] as $att) {
                        $att=(array)$att;
                        if($att["role"]=="MODERATOR") $data["Meetings"][$meeting["meetingID"]]["Liste"]["M"]=array($att["fullName"],($att["hasJoinedVoice"]=="true")? 1:0,($att["hasVideo"]=="true")? 1:0);
                        else $data["Meetings"][$meeting["meetingID"]]["Liste"]["T"][]=array($att["fullName"],($att["hasJoinedVoice"]=="true")? 1:0,($att["hasVideo"]=="true")? 1:0);
                    }
                }
                return($data);
            } else return(array("Anzahl"=>0,"Gesamt"=>0));
        } else return(-1);
    }
sprahl
  • 9
  • 2
  • Downvoted for the use of `(array)` rather than using the SimpleXML object directly. You're doing the right thing by extracting the data you need, but you don't need an array cast for that; e.g. `foreach($xml->meetings as $meeting)` will do exactly what you need if `$xml` is a `SimpleXMLElement`. – IMSoP Apr 24 '20 at 08:11