Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bbb-api-php
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
George Jiglau
bbb-api-php
Commits
50c9cdc9
Commit
50c9cdc9
authored
Dec 10, 2013
by
George Jiglau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
226 additions
and
0 deletions
+226
-0
README.md
README.md
+31
-0
bbb-api.php
bbb-api.php
+195
-0
No files found.
README.md
0 → 100644
View file @
50c9cdc9
bbb-api-php
===========
A PHP interface for the BigBlueButton API
Usage
-----
For a list of accepted parameters see the
[
BigBlueButton Wiki
](
https://code.google.com/p/bigbluebutton/wiki/API
)
.
<?php
$bbb = new BigBlueButton(BASE_URL, SECRET_SALT);
// Create a meeting
$meeting = $bbb->create(array(
'name' => 'Test meeting',
'meetingID' => 'test'
));
// Get the join URL for a meeting
$joinURL = $bbb->getJoinURL(array(
'fullName' => 'Smith Johnson',
'meetingID' => 'test',
'password' => $meeting->attendeePW
));
// After the meeting is done, end it
$bbb->end(array(
'meetingID' => $meeting->meetingID,
'password' => $meeting->moderatorPW
));
bbb-api.php
0 → 100644
View file @
50c9cdc9
<?php
class
BigBlueButton
{
private
$_bbbServerBaseURL
;
private
$_securitySalt
;
private
$_requestTimeout
;
function
__construct
(
$baseURL
,
$securitySalt
,
$timeout
=
10
)
{
$this
->
_bbbServerBaseURL
=
$baseURL
;
$this
->
_securitySalt
=
$securitySalt
;
$this
->
_requestTimeout
=
$timeout
;
}
private
function
_getURL
(
$method
,
$methodParams
)
{
/*
* Generate an URL for calling the method with the specified parameters
*/
$url
=
$this
->
_bbbServerBaseURL
.
'api/'
.
$method
;
// Sanitize parameters
array_walk
(
$methodParams
,
function
(
&
$item
)
{
$item
=
(
string
)
$item
;
});
$params
=
http_build_query
(
$methodParams
);
$checksum
=
sha1
(
$method
.
$params
.
$this
->
_securitySalt
);
if
(
empty
(
$params
))
{
return
$url
.
'?checksum='
.
$checksum
;
}
return
$url
.
'?'
.
$params
.
'&checksum='
.
$checksum
;
}
private
function
_makeRequest
(
$url
)
{
/*
* Make a request to the provided URL and return the response body
*/
if
(
!
extension_loaded
(
'curl'
))
{
throw
new
Exception
(
'The BigBlueButton API requires cURL'
);
}
$ch
=
curl_init
()
or
die
(
curl_error
());
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_CONNECTTIMEOUT
,
$this
->
_requestTimeout
);
$data
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
return
$data
;
}
private
function
_sXmlToObj
(
$sxml
)
{
if
(
!
$sxml
->
children
())
{
return
(
string
)
$sxml
;
}
$obj
=
new
stdClass
();
foreach
(
$sxml
->
children
()
as
$k
=>
$v
){
$obj
->
{
$k
}
=
$this
->
_sXmlToObj
(
$v
);
}
return
$obj
;
}
private
function
_callMethod
(
$method
,
$methodParams
)
{
/*
* Call the specified method and return the response as an XML element
*/
$url
=
$this
->
_getURL
(
$method
,
$methodParams
);
$response
=
$this
->
_makeRequest
(
$url
);
if
(
!
$response
)
{
return
false
;
}
$response
=
$this
->
_sXmlToObj
(
new
SimpleXMLElement
(
$response
));
if
(
!
isset
(
$response
->
returncode
))
{
return
false
;
}
return
$response
;
}
private
function
_checkParams
(
$paramSpec
,
$params
)
{
// Check for missing required parameters
foreach
(
$paramSpec
as
$param
=>
$req
)
{
if
(
!
$req
)
{
continue
;
}
if
(
!
isset
(
$params
[
$param
])
||
!
$params
[
$param
])
{
throw
new
Exception
(
sprintf
(
'Parameter "%s" missing or empty'
,
$param
));
}
}
// Check for extra parameters
foreach
(
$params
as
$param
=>
$val
)
{
if
(
!
isset
(
$paramSpec
[
$param
]))
{
trigger_error
(
sprintf
(
'Extra parameter "%s" in BBB API call'
,
$param
),
E_USER_NOTICE
);
}
}
}
public
function
create
(
$params
)
{
$paramSpec
=
array
(
'name'
=>
false
,
'meetingID'
=>
true
,
'attendeePW'
=>
false
,
'moderatorPW'
=>
false
,
'welcome'
=>
false
,
'dialNumber'
=>
false
,
'voiceBridge'
=>
false
,
'webVoice'
=>
false
,
'logoutURL'
=>
false
,
'record'
=>
false
,
'duration'
=>
false
,
'meta'
=>
false
);
$this
->
_checkParams
(
$paramSpec
,
$params
);
return
$this
->
_callMethod
(
'create'
,
$params
);
}
public
function
getJoinURL
(
$params
)
{
$paramSpec
=
array
(
'fullName'
=>
true
,
'meetingID'
=>
true
,
'password'
=>
true
,
'createTime'
=>
false
,
'userID'
=>
false
,
'webVoiceConf'
=>
false
,
'configToken'
=>
false
);
$this
->
_checkParams
(
$paramSpec
,
$params
);
return
$this
->
_getURL
(
'join'
,
$params
);
}
public
function
end
(
$params
)
{
$paramSpec
=
array
(
'meetingID'
=>
true
,
'password'
=>
true
);
$this
->
_checkParams
(
$paramSpec
,
$params
);
return
$this
->
_callMethod
(
'end'
,
$params
);
}
public
function
isMeetingRunning
(
$params
)
{
$paramSpec
=
array
(
'meetingID'
=>
true
);
$this
->
_checkParams
(
$paramSpec
,
$params
);
return
$this
->
_callMethod
(
'isMeetingRunning'
,
$params
);
}
public
function
getMeetings
()
{
return
$this
->
_callMethod
(
'getMeetings'
,
array
());
}
public
function
getMeetingInfo
(
$params
)
{
$paramSpec
=
array
(
'meetingID'
=>
true
,
'password'
=>
true
);
$this
->
_checkParams
(
$paramSpec
,
$params
);
return
$this
->
_callMethod
(
'getMeetingInfo'
,
$params
);
}
public
function
getRecordings
(
$params
)
{
$paramSpec
=
array
(
'meetingID'
=>
false
);
$this
->
_checkParams
(
$paramSpec
,
$params
);
return
$this
->
_callMethod
(
'getRecordings'
,
$params
);
}
public
function
publishRecordings
(
$params
)
{
$paramSpec
=
array
(
'recordID'
=>
true
,
'publish'
=>
true
);
$this
->
_checkParams
(
$paramSpec
,
$params
);
return
$this
->
_callMethod
(
'publishRecordings'
,
$params
);
}
public
function
deleteRecordings
(
$params
)
{
$paramSpec
=
array
(
'recordID'
=>
true
);
$this
->
_checkParams
(
$paramSpec
,
$params
);
return
$this
->
_callMethod
(
'deleteRecordings'
,
$params
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment