Skip to content

Instantly share code, notes, and snippets.

@nadavkav
Created March 19, 2020 19:36
Show Gist options
  • Save nadavkav/379f59d855fc089fab8c9ed1aeaaecce to your computer and use it in GitHub Desktop.
Save nadavkav/379f59d855fc089fab8c9ed1aeaaecce to your computer and use it in GitHub Desktop.
List online BBB rooms (PHP)
<?php
// List online BBB rooms
//
//
// https://docs.bigbluebutton.org/dev/api.html
// https://github.com/bigbluebutton/bigbluebutton-api-php
//
// echo sha1('getMeetings'.'gcAIBNoat3WN4oRioGxY9Ik5Xrfzm3KTi3KixyCVf4');
//
$bbb_api_getmeetings_xml = file_get_contents('https://bbb.your-website.info/bigbluebutton/api/getMeetings?checksum=7fd047728b989f368c3337a08f334a5');
$xml = simplexml_load_string($bbb_api_getmeetings_xml, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$meeting_array = json_decode($json,TRUE);
//var_dump($meeting_array['meetings']);
//die;
$meetingid = 0;
$display_meeting = [];
foreach($meeting_array['meetings']['meeting'] as $meeting) {
$display_meeting[$meetingid]['meetingName'] = $meeting['meetingName'];
$display_meeting[$meetingid]['createDate'] = $meeting['createDate'];
$display_meeting[$meetingid]['running'] = $meeting['running'];
$display_meeting[$meetingid]['moderatorCount'] = $meeting['moderatorCount'];
$display_meeting[$meetingid]['participantCount'] = $meeting['participantCount'];
$display_meeting[$meetingid]['videoCount'] = $meeting['videoCount'];
$display_meeting[$meetingid]['voiceParticipantCount'] = $meeting['voiceParticipantCount'];
$meetingid++;
}
//var_dump($display_meeting);
//echo array2Html($meeting_array['meetings']);
echo array2Html($display_meeting);
function array2Html($array, $table = true)
{
$out = '';
foreach ($array as $key => $value) {
if (is_array($value)) {
if (!isset($tableHeader)) {
$tableHeader =
'<th>' .
implode('</th><th>', array_keys($value)) .
'</th>';
}
array_keys($value);
$out .= '<tr>';
$out .= array2Html($value, false);
$out .= '</tr>';
} else {
$out .= "<td style='border: 1px solid black;'>$value</td>";
}
}
if ($table) {
return '<table>' . $tableHeader . $out . '</table>';
} else {
return $out;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment