-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathBbb.php
177 lines (135 loc) · 4.61 KB
/
Bbb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// ------------------------------------------------------------------------
/**
* BBB Library Class (BigBlueButton Wrapper Class)
*
* This CI library is based on BigBlueButton's API (http://bigbluebutton.org)
*
* This file provides an easier and simpler way to use BigBlueButton on
* CodeIgniter PHP Framework. This file is ONLY intended to be a CI wrapper
* of BigBlueButton's official API.
*
* BigBlueButton is an open source web conferencing system built
* on over fourteen open source components to create an integrated solution
* that runs on Mac, UNIX, or PC computers.
* BigBlueButton is trademark of BigBlueButton Inc.
*
* The class requires the use of the BBB config file.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Web Conferencing
* @author Vasilis Lolos <vlolos@me.com>
* @copyright Copyright (c) 2011, /~https://github.com/lolos/BigBlueButton-CodeIgniter
*
*/
// ------------------------------------------------------------------------
class Bbb {
function Bbb()
{
$this->CI =& get_instance();
$this->CI->load->helper('url');
$this->CI->load->config('bbb_config');
$this->api_url = 'http://'.$this->CI->config->item('bbb_server_domain').'/bigbluebutton/api/';
$this->security_salt = $this->CI->config->item('bbb_security_salt');
$this->max_participants = $this->CI->config->item('bbb_max_participants');
}
protected function get_query_string($params_input)
{
$params = array();
foreach ( $params_input as $name => $value )
array_push($params, urlencode($name).'='.urlencode($value));
return implode('&', $params);
}
protected function get_checksum($callname, $params)
{
return sha1($callname.$this->get_query_string($params).$this->security_salt);
}
protected function get_call_url($callname, $params)
{
$params->checksum = $this->get_checksum($callname, $params);
return $this->api_url.$callname.'?'.$this->get_query_string($params);
}
protected function get_xml_response($callname, $params)
{
$requestUrl = $this->get_call_url($callname, $params);
if ( extension_loaded('curl') )
{
$ch = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$response = curl_exec($ch);
curl_close( $ch );
if ( $response )
return new SimpleXMLElement($response);
}
return simplexml_load_file($requestUrl);
}
public function create_meeting($meetingID, $name, $duration=60, $logoutURL=NULL, $moderatorPW=NULL, $attendeePW=NULL, $welcome=NULL)
{
global $CFG;
$params->name = $name;
$params->meetingID = $meetingID;
$params->maxParticipants = $this->max_participants;
$params->duration = $duration;
if (! empty($logoutURL) )
$params->logoutURL = $logoutURL;
if (! empty($moderatorPW) )
$params->moderatorPW = $moderatorPW;
if (! empty($attendeePW) )
$params->attendeePW = $attendeePW;
if (! empty($meeting) )
$params->welcome = $welcome;
return $this->get_xml_response('create', $params);
}
public function join_meeting($meetingID, $userID, $fullName, $password)
{
$params->fullName = $fullName;
$params->meetingID = $meetingID;
$params->password = $password;
$params->userID = $userID;
$requestUrl = $this->get_call_url('join', $params);
redirect($requestUrl);
}
public function is_meeting_running($meetingID)
{
$params['meetingID'] = $meetingID;
$params['checksum'] = $this->get_checksum('isMeetingRunning', $params);
$xml = $this->get_xml_response('isMeetingRunning', $params);
if ( $xml->running == 'true' )
return TRUE;
}
public function end_meeting($meetingID, $moderatorPW)
{
$params->meetingID = $meetingID;
$params->password = $moderatorPW;
return $this->get_xml_response('end', $params);
}
public function get_meeting_info($meetingID, $moderatorPW)
{
$params->meetingID = $meetingID;
$params->password = $moderatorPW;
return $this->get_xml_response('getMeetingInfo', $params);
}
public function get_meetings()
{
$params->random = rand()*1000;
$xml = $this->get_xml_response('getMeetings', $params);
if( $xml && $xml->returncode == 'SUCCESS' )
{
if( count($xml->meetings) && count($xml->meetings->meeting) )
{
$meetings = array();
foreach ( $xml->meetings->meeting as $m )
{
$meeting = $this->get_meeting_info($m->meetingID, $m->moderatorPW);
array_push($meetings, $meeting);
}
return $meetings;
}
}
}
}
/* End of file Bbb.php */