/** Сниппет возвращает с сервера BBB информацию о встречах */ if (!($bbb = $modx->getService('bbb', 'bbb', $modx->getOption('bbb_core_path', null, $modx->getOption('core_path') . 'components/bbb/') . 'model/bbb/'))) { $modx->log(xPDO::LOG_LEVEL_ERROR, 'Ошибка! Не удается проинициализировать bbb.', '', 'getMeetings', __FILE__, __LINE__); } //$modx->log(xPDO::LOG_LEVEL_ERROR,print_r($scriptProperties,true)); $include_path = $modx->getOption('bbb_core_path', null, $modx->getOption('core_path') . 'components/bbb/') . 'includes/'; $tpl = $modx->getOption('tpl', $scriptProperties, null, true); require_once $include_path . 'bbb-api.php'; //Подключаем api BigBlueButton $bbb_server = new BigBlueButton(); $itsAllGood = true; try { $answer = $bbb_server->getMeetingsWithXmlResponseArray(); } catch (Exception $e) { $modx->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage()); $itsAllGood = false; } if ($answer == null) { // Если в ответ получен null, то возможно не откликается сервер BBB $modx->log(xPDO::LOG_LEVEL_ERROR, 'Не получен никакой ответ от сервера BBB в ответ на getMeetingsWithXmlResponseArray, Возможно, нет соединения с сервером BBB '); return false; } else { $modx->setPlaceholder('total_meetings', count($answer) - 3); $pls = array(); $output = ''; foreach ($answer as $kod => $meeting) { if ($kod !== 'message' and $kod !== 'messageKey' and $kod !== 'returncode') { foreach ($meeting as $id => $value) {
/** * @brief get number of active rooms * @param type $salt * @param type $bbb_url * @return int */ function get_active_rooms($salt,$bbb_url) { $sum = 0; // Instatiate the BBB class: $bbb = new BigBlueButton($salt,$bbb_url); $meetings = $bbb->getMeetingsWithXmlResponseArray(); foreach ($meetings as $meeting) { $mid = $meeting['meetingId']; $pass = $meeting['moderatorPw']; if ($mid != null) { $sum += 1; } } return $sum; }
// Require the bbb-api file: require_once '../includes/bbb-api.php'; // Instatiate the BBB class: $bbb = new BigBlueButton(); /* ___________ GET MEETINGS FROM BBB SERVER ______ */ /* */ /* ---DEBUG - useful for manually checking the raw xml results. $test = $bbb->getGetMeetingsUrl(); echo $test; ---END DEBUG */ $itsAllGood = true; try { $result = $bbb->getMeetingsWithXmlResponseArray(); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; $itsAllGood = false; } if ($itsAllGood == true) { // If it's all good, then we've interfaced with our BBB php api OK: if ($result == null) { // If we get a null response, then we're not getting any XML back from BBB. echo "Failed to get any response. Maybe we can't contact the BBB server."; } else { // We got an XML response, so let's see what it says: if ($result['returncode'] == 'SUCCESS') { // Then do stuff ... echo "<p>We got some meeting info from BBB:</p>"; // You can parse this array how you like. For now we just do this: