PHP code example of littleredbutton / bigbluebutton-api-php
1. Go to this page and download the library: Download littleredbutton/bigbluebutton-api-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
littleredbutton / bigbluebutton-api-php example snippets
use BigBlueButton\BigBlueButton;
$bbb = new BigBlueButton($apiUrl, $apiSecret);
use BigBlueButton\Parameters\IsMeetingRunningParameters;
$meetingParams = new IsMeetingRunningParameters('foobar');
try {
$response = $bbb->isMeetingRunning($meetingParams);
if (!$response->success() && !$response->failed()) {
// invalid url
}
if (!$response->success()) {
// invalid secret
}
// url and secret are valid
} catch (\Exception $e) {
// invalid url
}
$version = $bbb->getApiVersion()->getVersion();
use BigBlueButton\Parameters\CreateMeetingParameters;
$createMeetingParams = new CreateMeetingParameters($meetingID, $meetingName);
$createMeetingResponse = $bbb->createMeeting($createMeetingParams);
if ($createMeetingResponse->success()) {
// process after room created
}
use BigBlueButton\Parameters\JoinMeetingParameters;
use BigBlueButton\Enum\Role;
$joinMeetingParams = new JoinMeetingParameters($room->uid, $displayname, Role::VIEWER);
$joinMeetingParams->setCreateTime($createMeetingResponse->getCreationTime());
$joinMeetingParams->setRedirect(true);
$joinUrl = $bbb->getJoinMeetingURL($joinMeetingParams);
// e.g. header('Location:' . $joinUrl);
use BigBlueButton\Parameters\EndMeetingParameters;
$endMeetingParams = new EndMeetingParameters($meetingID);
$response = $bbb->endMeeting($endMeetingParams);
$response = $bbb->getMeetings();
if ($response->failed()) {
// error handling
}
$meetings = $response->getMeetings();
// e.g. $meetings[0]->getMeetingName();
use BigBlueButton\Parameters\IsMeetingRunningParameters;
$isMeetingRunningParams = new IsMeetingRunningParameters($meetingId);
$response = $bbb->isMeetingRunning($isMeetingRunningParams);
if ($response->success() && $response->isRunning()) {
// meeting is running
}
use BigBlueButton\Parameters\GetMeetingInfoParameters;
$getMeetingInfoParams = new GetMeetingInfoParameters($meetingID);
$response = $bbb->getMeetingInfo($getMeetingInfoParams);
if ($response->failed()) {
// error handling
}
// process $response->getRawXml();
use BigBlueButton\Parameters\GetRecordingsParameters;
$recordingParams = new GetRecordingsParameters();
$recordingParams->setRecordID($recordId); // omit to get a list of all recordings
$recordingParams->setState('any');
$response = $bbb->getRecordings($recordingParams);
if (!$response->success()) {
// handle error
}
$records = $response->getRecords();
// e.g. $records[0]->getParticipantCount();
use BigBlueButton\Parameters\PublishRecordingsParameters;
$publishRecordingsParams = new PublishRecordingsParameters($recordingId, $publish);
$response = $bbb->publishRecordings($publishRecordingsParams);
if ($response->success() && $response->isPublished()) {
// record was published
}
use BigBlueButton\Parameters\DeleteRecordingsParameters;
$deleteRecordingsParams= new DeleteRecordingsParameters($recordingID);
$response = $bbb->deleteRecordings($deleteRecordingsParams);
if ($response->success()) {
// meeting was deleted
}