Connect with BigBlueButton in easy 2 steps using PHP

In this article, I'll show you how to connect/join with BigBlueButton using PHP. I'm going to use the bigbluebutton-api-php library in this case. This library is very simple to use and has excellent support.

1) The first step is to install the bigbluebutton-api-php library. You must have composer installed on your system. Now, in your local development environment, create a directory and navigate to it using terminal or cmd to run:

composer require littleredbutton/bigbluebutton-api-php

This will install bigbluebutton-api-php along with all necessary packages. If you do not want to use composer, you can download the most recent library as a zip file from our MynaParrot github repo. After downloading, unzip the file and place it in a directory. At that point, you'll need to modify the include path to match your file structure.

2) Create a PHP file. I've named it easybbb.php

<?php

include __DIR__ . "/vendor/autoload.php";

use BigBlueButton\BigBlueButton;
use BigBlueButton\Parameters\IsMeetingRunningParameters;
use BigBlueButton\Parameters\CreateMeetingParameters;
use BigBlueButton\Parameters\JoinMeetingParameters;

$apiUrl = "https://api.mynaparrot.com/clientid/bigbluebutton/";
$salt = "api_key or salt";
$meetingId = "test_01"; 
$goFurther = false;
$isMeetingRunning = false;

$bbb = new BigBlueButton($apiUrl, $salt);

// Let's first check if the meeting is already running or not.

$meetingRunningParams = new IsMeetingRunningParameters($meetingId);

try {
    $response = $bbb->isMeetingRunning($meetingRunningParams);

    if($response->success()){
        $isMeetingRunning = $response->isRunning();
        $goFurther = true;
    }else{
        echo $response->getMessage() .  "\n";
    }
    
} catch (\Exception $e) {
    echo $e->getMessage() . "\n";
}

if (!$goFurther) {
    return;
}

if (!$isMeetingRunning) {
    // So, meeting isn't running. We'll create a new meeting.
    $meetingName = "My Test Meeting";
    $attendee_password = "student";
    $moderator_password = "teacher";

    // https://github.com/littleredbutton/bigbluebutton-api-php/blob/master/src/Parameters/CreateMeetingParameters.php
    $createMeetingParams = new CreateMeetingParameters($meetingId, $meetingName);
    $createMeetingParams->setAttendeePassword($attendee_password);
    $createMeetingParams->setModeratorPassword($moderator_password);
    $createMeetingParams->setMaxParticipants(10);
    $createMeetingParams->addPresentation("http://classroom2.mynaparrot.es/mynadefault.pdf");
    $createMeetingParams->setLogoutURL("https://mynaparrot.com/");
    $createMeetingParams->setAllowModsToUnmuteUsers(true);
    $createMeetingParams->setDuration(60); // duration in minutes. 0 = unlimited

    // Optional. Metadata is used to store customized information. This data can be retrieved during get recordings.
    //$createMeetingParams->addMeta("library", "littleredbutton/bigbluebutton-api-php");
    //$createMeetingParams->addMeta("php_version", "7.4");

    try {
        $createMeetingResponse = $bbb->createMeeting($createMeetingParams);
        if ($createMeetingResponse->success()) {
            //https://github.com/littleredbutton/bigbluebutton-api-php/blob/master/src/Responses/CreateMeetingResponse.php
            //echo $createMeetingResponse->getInternalMeetingId();
            $isMeetingRunning = true;
        }else{
            echo $createMeetingResponse->getMessage() .  "\n";
            $goFurther = false;
        }
    }catch (\Exception $e){
        echo $e->getMessage() . "\n";
        $goFurther = false;
    }
}

if (!$goFurther) {
    return;
}

if($isMeetingRunning){
    $displayname = "Jibon"; // your name
    $password = "teacher"; // This password can either be a moderator password or an attendee password. If you use the moderator password, the user will join as a moderator; otherwise, the user will join as an attendee. 

    //https://github.com/littleredbutton/bigbluebutton-api-php/blob/master/src/Parameters/JoinMeetingParameters.php
    $joinMeetingParams = new JoinMeetingParameters($meetingId, $displayname, $password);
    //$joinMeetingParams->setUserId($userid); // This option is useful if you don't want the same user to be able to join from multiple devices. A unique user id or value must be sent in this case. 
    $joinMeetingParams->setJoinViaHtml5(true);
    $joinMeetingParams->setRedirect(true);

    //https://github.com/littleredbutton/bigbluebutton-api-php/blob/master/src/Parameters/UserDataParameters.php
    //https://docs.bigbluebutton.org/2.2/customize.html#passing-custom-parameters-to-the-client-on-join
    $joinMeetingParams->addUserData("bbb_record_video", true);

    $joinUrl = $bbb->getJoinMeetingURL($joinMeetingParams);

    header('Location:' . $joinUrl);
}

 

To get BigBlueButton Recordings:

1) I'm creating another file easyGetRecordings.php

<?php
include __DIR__ . "/vendor/autoload.php";

use BigBlueButton\BigBlueButton;
use BigBlueButton\Parameters\GetRecordingsParameters;

$apiUrl = "https://api.mynaparrot.com/clientid/bigbluebutton/";
$salt = "api_key or salt";
$meetingId = "test_01";

$bbb = new BigBlueButton($apiUrl, $salt);

//https://github.com/littleredbutton/bigbluebutton-api-php/blob/master/src/Parameters/GetRecordingsParameters.php

$recordingParams = new GetRecordingsParameters();
$recordingParams->setMeetingId($meetingId); // omit to get a list of all recordings

try {
    $response = $bbb->getRecordings($recordingParams);

    if ($response->success()) {
        $records = $response->getRecords();
        if($records){
            foreach ($records as $key => $record){
              //https://github.com/littleredbutton/bigbluebutton-api-php/blob/master/src/Core/Record.php
              echo $record->getPlaybackUrl() . "<br>";
//            echo "<pre>";
//            print_r($record->getMetas());
//            echo "</pre>";
            }
        }else{
            echo $response->getMessage() .  "\n";
        }
    }else{
        echo $response->getMessage() .  "\n";
    }
}catch (\Exception $e) {
    echo $e->getMessage() . "\n";
}

 

That's all. I've written description in the code. Now you can follow that as example.

Checkout our BigBlueButton services & BigBlueButton Hosting.

 

 

We use cookies

Utilizziamo i cookie sul nostro sito Web. Alcuni di essi sono essenziali per il funzionamento del sito, mentre altri ci aiutano a migliorare questo sito e l'esperienza dell'utente (cookie di tracciamento). Puoi decidere tu stesso se consentire o meno i cookie. Ti preghiamo di notare che se li rifiuti, potresti non essere in grado di utilizzare tutte le funzionalità del sito.