Skip to content

Commit e2415a8

Browse files
committed
Moved install and usage example to INSTALL.md
1 parent 04b0d9b commit e2415a8

2 files changed

Lines changed: 238 additions & 229 deletions

File tree

INSTALL.md

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# Full usage sample
2+
## Introduction
3+
4+
You have been using BigBlueButton for years or you are still discovering it, and you have PHP within your solutions
5+
sphere and considering managing your BigBlueButton meetings with PHP, we are writing this tutorial right for you
6+
and your team.
7+
8+
BigBlueButton officially offers a PHP library to use for its API. In this tutorial you will learn how to use this PHP
9+
library to create a meeting then join it.
10+
11+
## Pre-requisites
12+
13+
Before we can show you how to use the library, it is important to have the following point done:
14+
- 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.
15+
- 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.
16+
- curl, mbstring, simple-xml PHP extensions. They are active by default in most PHP distributions.
17+
- A running HTTP server, Apache2 or nginx.
18+
- Composer PHP dependency manager pre-installed.
19+
20+
## Installation and configuration
21+
22+
First, we need to create our composer project.
23+
24+
```
25+
composer init –name 'bigbluebutton-join-form'
26+
```
27+
28+
Then we need to add the library available on packagist.
29+
30+
```
31+
composer require bigbluebutton/bigbluebutton-api-php
32+
```
33+
34+
Once we have defined the required dependency, we need to install it using the command below.
35+
36+
```
37+
composer install -o --no-dev
38+
```
39+
40+
Adding `--no-dev` options, means that we omit development packages that are mainly used to unit test the library.
41+
42+
The library package has now been downloaded to `vendor` directory in your project root. A configuration final step
43+
is required for the library.
44+
45+
As you know, the call BigBlueButton API you need the server URL and the shred secret. You can get them from you
46+
BigBlueButton server with 'bbb-conf' http://docs.bigbluebutton.org/install/bbb-conf.html#--secret
47+
48+
Once you have them, create two environment variables. For Apache2 you can use the `SetEnv` directive or the
49+
`fastcgi_param` for nginx. For Apache2, we advise putting the variables in the `/etc/apache2/envvars` to keep themaway from your source code repository.
50+
51+
`BBB_SECRET='8cd8ef52e8e101574e400365b55e11a6'`
52+
53+
`BBB_SERVER_BASE_URL='http://test-install.blindsidenetworks.com/bigbluebutton/'`
54+
55+
## Set up a basic join meeting form
56+
57+
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.
58+
59+
```html
60+
<!DOCTYPE html>
61+
<html lang="en">
62+
<style>
63+
body {
64+
padding : 20px 40px;
65+
font-size : 14px;
66+
font-family : Verdana, Tahoma, sans-serif;
67+
}
68+
69+
h2 {
70+
color : #273E83;
71+
}
72+
73+
input:not([type=checkbox]), select {
74+
border-radius : 3px;
75+
padding : 10px;
76+
border : 1px solid #E2E2E2;
77+
width : 200px;
78+
color : #666666;
79+
box-shadow : rgba(0, 0, 0, 0.1) 0 0 4px;
80+
}
81+
82+
input:hover, select:hover,
83+
input:focus, select:focus {
84+
border : 1px solid #273E83;
85+
box-shadow : rgba(0, 0, 0, 0.2) 0 0 6px;
86+
}
87+
88+
.form label {
89+
margin-left : 12px;
90+
color : #BBBBBB;
91+
}
92+
93+
.submit input {
94+
background-color : #273E83;
95+
color : #FFFFFF;
96+
border-radius : 3px;
97+
}
98+
99+
</style>
100+
<head>
101+
<meta charset="UTF-8">
102+
<title>BigBlueButton Join Meeting - PHP Form</title>
103+
</head>
104+
<body>
105+
<h2>BigBlueButton Join Meeting - PHP Form</h2>
106+
107+
<form class="form" action="join_bbb.php" method="post">
108+
109+
<p class="username">
110+
<input type="text" name="username" id="username" placeholder="University Teacher"/>
111+
<label for="username">Username</label>
112+
</p>
113+
114+
<p class="role">
115+
<select name="role" id="role">
116+
<option value="moderator">Moderator</option>
117+
<option value="attendee">Attendee</option>
118+
</select>
119+
<label for="role">Role</label>
120+
</p>
121+
122+
<p class="meeting">
123+
<select name="meeting" id="meeting">
124+
<option value="mc">Molecular Chemistry</option>
125+
<option value="it">Information Theory</option>
126+
<option value="pm">Project Management</option>
127+
</select>
128+
<label for="meeting">Course</label>
129+
</p>
130+
131+
<p class="web">
132+
<input type="checkbox" name="html5" id="html5"/>
133+
<label for="html5">Use HTML5</label>
134+
</p>
135+
136+
<p class="submit">
137+
<input type="submit" value="Join"/>
138+
</p>
139+
</form>
140+
</body>
141+
</html>
142+
```
143+
144+
The HTML form is now ready. Let’s see how to handle posted data step by step. All data will be sent then
145+
processed by `join-bbb.php` file.
146+
147+
## Preparing PHP form processor
148+
149+
Do you remember we used composer to install the library? Composer creates a file named `autoload.php` inside
150+
`vendor` directory. Just import it to load the necessary classes.
151+
152+
```php
153+
<?php
154+
155+
require_once './vendor/autoload.php';
156+
```
157+
158+
After asking PHP to use the file `./vendor/autoload.php` to handle the necessary classes loading. We define our
159+
meeting names in the `$meetings`, then we define the `$passwords`, both in associative arrays.
160+
161+
```php
162+
// Define meetings names
163+
$meetings = array('mc' => 'Molecular Chemistry',
164+
'it' => 'Information Theory',
165+
'pm' => 'Project Management');
166+
167+
$passwords = array('moderator' => 'mPass',
168+
'attendee' => 'aPass');
169+
```
170+
171+
The PHP API offers an easy way to handle calls. Creating an instance of `BigBlueButton` class without giving any
172+
parameter. After it we are storing the meeting id we got from our form inside the `$meetingId` variable.
173+
174+
```php
175+
// Init BigBlueButton API
176+
$bbb = new BigBlueButton();
177+
$meetingId = $HTTP_POST_VARS['meeting'];
178+
```
179+
180+
## Creating the meeting
181+
182+
To create a meeting, only two parameters are mandatory: the meeting ID and the meeting name. For security reasons we
183+
discourage leaving the moderator password and the attendee password empty. For that reason, we are filling them in
184+
the `CreateMeetingParameters` instance.
185+
186+
```php
187+
// Create the meeting
188+
$createParams = new CreateMeetingParameters($meetingId, $meetings[$meetingId]);
189+
$createParams = $createParams->setModeratorPassword($passwords['moderator'])
190+
->setAttendeePassword($passwords['attendee']);
191+
$bbb->createMeeting($createParams);
192+
```
193+
194+
## Joining the meeting
195+
196+
Joining the meeting is done in two steps. In the first step we create an instance of `CreateMeetingParameters` and fill
197+
the previously saved `$meetingId`, then `username` and `role` values from POST values. Don’t forget to set `redirect`
198+
to `true` if you want an immediate redirection to the meeting. We also pass `true` to `setJoinViaHtml5` to join the
199+
meeting using the HTML5 client.
200+
201+
```php
202+
// Send a join meeting request
203+
$joinParams = new JoinMeetingParameters($meetingId, $HTTP_POST_VARS['username'], $passwords[$HTTP_POST_VARS['role']]);
204+
$joinParams->setRedirect(true)
205+
```
206+
207+
Lastly, we ask PHP to follow the join meeting redirection using the `header` function. The redirection will be done by
208+
BigBlueButton by calling `$bbb->getJoinMeetingURL($joinParams))`. You should now see the meeting page.
209+
210+
```php
211+
// Join the meeting by redirecting the user to the generated URL
212+
header('Status: 301 Moved Permanently', false, 301);
213+
header('Location:' . $bbb->getJoinMeetingURL($joinParams));
214+
```
215+
216+
## Conclusion
217+
You have discovered how to setup a BigBlueButton meeting then join it using the PHP API client library. Go ahead and
218+
explore the library features to implement your own meeting management system for BigBlueButton.

0 commit comments

Comments
 (0)