Skip to content

Commit 04b0d9b

Browse files
committed
Added 'Full usage sample' section to README.md
1 parent 878c1a4 commit 04b0d9b

1 file changed

Lines changed: 221 additions & 1 deletion

File tree

README.md

Lines changed: 221 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ use BigBlueButton\Parameters\JoinMeetingParameters;
113113

114114
$bbb = new BigBlueButton();
115115

116-
$joinMeetingParams = new JoinMeetingParameters($meetingID, $name, $password); // $moderator_password for moderator
116+
// $moderator_password for moderator
117+
$joinMeetingParams = new JoinMeetingParameters($meetingID, $name, $password);
117118
$joinMeetingParams->setRedirect(true);
118119
$url = $bbb->getJoinMeetingURL($joinMeetingParams);
119120

@@ -188,6 +189,225 @@ if ($response->getReturnCode() == 'SUCCESS') {
188189
```
189190

190191

192+
## Full usage sample
193+
### Introduction
194+
195+
You have been using BigBlueButton for years or you are still discovering it, and you have PHP within your solutions
196+
sphere and considering managing your BigBlueButton meetings with PHP, we are writing this tutorial right for you
197+
and your team.
198+
199+
BigBlueButton officially offers a PHP library to use for its API. In this tutorial you will learn how to use this PHP
200+
library to create a meeting then join it.
201+
202+
### Pre-requisites
203+
204+
Before we can show you how to use the library, it is important to have the following point done:
205+
- BigBlueButton server installed. Easy enough, it takes 15 minutes or less. Just follow this link https://bigbluebutton.org/2018/03/28/install-bigbluebutton-in-15-minutes/ if not already done.
206+
- PHP 7.0 or higher. Whether the library is compatible with previous version of PHP 5.4, 5.5 and 5.6, we highly discourage you to use it on those versions to avoid any unwanted behavior.
207+
- curl, mbstring, simple-xml PHP extensions. They are active by default in most PHP distributions.
208+
- A running HTTP server, Apache2 or nginx.
209+
- Composer PHP dependency manager pre-installed.
210+
211+
### Installation and configuration
212+
213+
First, we need to create our composer project.
214+
215+
```
216+
composer init –name 'bigbluebutton-join-form'
217+
```
218+
219+
Then we need to add the library available on packagist.
220+
221+
```
222+
composer require bigbluebutton/bigbluebutton-api-php
223+
```
224+
225+
Once we have defined the required dependency, we need to install it using the command below.
226+
227+
```
228+
composer install -o --no-dev
229+
```
230+
231+
Adding `--no-dev` options, means that we omit development packages that are mainly used to unit test the library.
232+
233+
The library package has now been downloaded to `vendor` directory in your project root. A configuration final step
234+
is required for the library.
235+
236+
As you know, the call BigBlueButton API you need the server URL and the shred secret. You can get them from you
237+
BigBlueButton server with 'bbb-conf' http://docs.bigbluebutton.org/install/bbb-conf.html#--secret
238+
239+
Once you have them, create two environment variables. For Apache2 you can use the `SetEnv` directive or the
240+
`fastcgi_param` for nginx. For Apache2, we advise putting the variables in the `/etc/apache2/envvars` to keep themaway from your source code repository.
241+
242+
`BBB_SECRET='8cd8ef52e8e101574e400365b55e11a6'`
243+
244+
`BBB_SERVER_BASE_URL='http://test-install.blindsidenetworks.com/bigbluebutton/'`
245+
246+
### Set up a basic join meeting form
247+
248+
Let’s go ahead and create our HTML form to join BigBlueButton meeting. The contact form will contain the following fields: username, a combo-box for the meeting name, a second combo-box for the user role and a checkbox for the client type.
249+
250+
```html
251+
<!DOCTYPE html>
252+
<html lang="en">
253+
<style>
254+
body {
255+
padding : 20px 40px;
256+
font-size : 14px;
257+
font-family : Verdana, Tahoma, sans-serif;
258+
}
259+
260+
h2 {
261+
color : #273E83;
262+
}
263+
264+
input:not([type=checkbox]), select {
265+
border-radius : 3px;
266+
padding : 10px;
267+
border : 1px solid #E2E2E2;
268+
width : 200px;
269+
color : #666666;
270+
box-shadow : rgba(0, 0, 0, 0.1) 0 0 4px;
271+
}
272+
273+
input:hover, select:hover,
274+
input:focus, select:focus {
275+
border : 1px solid #273E83;
276+
box-shadow : rgba(0, 0, 0, 0.2) 0 0 6px;
277+
}
278+
279+
.form label {
280+
margin-left : 12px;
281+
color : #BBBBBB;
282+
}
283+
284+
.submit input {
285+
background-color : #273E83;
286+
color : #FFFFFF;
287+
border-radius : 3px;
288+
}
289+
290+
</style>
291+
<head>
292+
<meta charset="UTF-8">
293+
<title>BigBlueButton Join Meeting - PHP Form</title>
294+
</head>
295+
<body>
296+
<h2>BigBlueButton Join Meeting - PHP Form</h2>
297+
298+
<form class="form" action="join_bbb.php" method="post">
299+
300+
<p class="username">
301+
<input type="text" name="username" id="username" placeholder="University Teacher"/>
302+
<label for="username">Username</label>
303+
</p>
304+
305+
<p class="role">
306+
<select name="role" id="role">
307+
<option value="moderator">Moderator</option>
308+
<option value="attendee">Attendee</option>
309+
</select>
310+
<label for="role">Role</label>
311+
</p>
312+
313+
<p class="meeting">
314+
<select name="meeting" id="meeting">
315+
<option value="mc">Molecular Chemistry</option>
316+
<option value="it">Information Theory</option>
317+
<option value="pm">Project Management</option>
318+
</select>
319+
<label for="meeting">Course</label>
320+
</p>
321+
322+
<p class="web">
323+
<input type="checkbox" name="html5" id="html5"/>
324+
<label for="html5">Use HTML5</label>
325+
</p>
326+
327+
<p class="submit">
328+
<input type="submit" value="Join"/>
329+
</p>
330+
</form>
331+
</body>
332+
</html>
333+
```
334+
335+
The HTML form is now ready. Let’s see how to handle posted data step by step. All data will be sent then
336+
processed by `join-bbb.php` file.
337+
338+
### Preparing PHP form processor
339+
340+
Do you remember we used composer to install the library? Composer creates a file named `autoload.php` inside
341+
`vendor` directory. Just import it to load the necessary classes.
342+
343+
```php
344+
<?php
345+
346+
require_once './vendor/autoload.php';
347+
```
348+
349+
After asking PHP to use the file `./vendor/autoload.php` to handle the necessary classes loading. We define our
350+
meeting names in the `$meetings`, then we define the `$passwords`, both in associative arrays.
351+
352+
```php
353+
// Define meetings names
354+
$meetings = array('mc' => 'Molecular Chemistry',
355+
'it' => 'Information Theory',
356+
'pm' => 'Project Management');
357+
358+
$passwords = array('moderator' => 'mPass',
359+
'attendee' => 'aPass');
360+
```
361+
362+
The PHP API offers an easy way to handle calls. Creating an instance of `BigBlueButton` class without giving any
363+
parameter. After it we are storing the meeting id we got from our form inside the `$meetingId` variable.
364+
365+
```php
366+
// Init BigBlueButton API
367+
$bbb = new BigBlueButton();
368+
$meetingId = $HTTP_POST_VARS['meeting'];
369+
```
370+
371+
### Creating the meeting
372+
373+
To create a meeting, only two parameters are mandatory: the meeting ID and the meeting name. For security reasons we
374+
discourage leaving the moderator password and the attendee password empty. For that reason, we are filling them in
375+
the `CreateMeetingParameters` instance.
376+
377+
```php
378+
// Create the meeting
379+
$createParams = new CreateMeetingParameters($meetingId, $meetings[$meetingId]);
380+
$createParams = $createParams->setModeratorPassword($passwords['moderator'])
381+
->setAttendeePassword($passwords['attendee']);
382+
$bbb->createMeeting($createParams);
383+
```
384+
385+
### Joining the meeting
386+
387+
Joining the meeting is done in two steps. In the first step we create an instance of `CreateMeetingParameters` and fill
388+
the previously saved `$meetingId`, then `username` and `role` values from POST values. Don’t forget to set `redirect`
389+
to `true` if you want an immediate redirection to the meeting. We also pass `true` to `setJoinViaHtml5` to join the
390+
meeting using the HTML5 client.
391+
392+
```php
393+
// Send a join meeting request
394+
$joinParams = new JoinMeetingParameters($meetingId, $HTTP_POST_VARS['username'], $passwords[$HTTP_POST_VARS['role']]);
395+
$joinParams->setRedirect(true)
396+
```
397+
398+
Lastly, we ask PHP to follow the join meeting redirection using the `header` function. The redirection will be done by
399+
BigBlueButton by calling `$bbb->getJoinMeetingURL($joinParams))`. You should now see the meeting page.
400+
401+
```php
402+
// Join the meeting by redirecting the user to the generated URL
403+
header('Status: 301 Moved Permanently', false, 301);
404+
header('Location:' . $bbb->getJoinMeetingURL($joinParams));
405+
```
406+
407+
### Conclusion
408+
You have discovered how to setup a BigBlueButton meeting then join it using the PHP API client library. Go ahead and
409+
explore the library features to implement your own meeting management system for BigBlueButton.
410+
191411
## Submitting bugs and feature requests
192412

193413
Bugs and feature request are tracked on [GitHub](https://github.com/bigbluebutton/bigbluebutton-api-php/issues)

0 commit comments

Comments
 (0)