bbb_api.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <?php
  2. /*
  3. Copyright 2010 Blindside Networks
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. Versions:
  16. 1.0 -- Initial version written by DJP
  17. (email: djp [a t ] architectes DOT .org)
  18. 1.1 -- Updated by Omar Shammas and Sebastian Schneider
  19. (email : omar DOT shammas [a t ] g m ail DOT com)
  20. (email : seb DOT sschneider [ a t ] g m ail DOT com)
  21. 1.2 -- Updated by Omar Shammas
  22. (email : omar DOT shammas [a t ] g m ail DOT com)
  23. 1.3 -- Refactored by Peter Mentzer
  24. (email : peter@petermentzerdesign.com)
  25. - This update will BREAK your external existing code if
  26. you've used the previous versions <= 1.2 already so:
  27. -- update your external code to use new method names if needed
  28. -- update your external code to pass new parameters to methods
  29. - Working example of joinIfRunning.php now included
  30. - Added support for BBB 0.8b recordings
  31. - Now using Zend coding, naming and style conventions
  32. - Refactored methods to accept standardized parameters & match BBB API structure
  33. -- See included samples for usage examples
  34. */
  35. class BigBlueButtonBN
  36. {
  37. private $_securitySalt;
  38. private $_bbbServerBaseUrl;
  39. public function __construct()
  40. {
  41. /*
  42. Establish just our basic elements in the constructor:
  43. */
  44. // BASE CONFIGS - set these for your BBB server in config.php and they will
  45. // simply flow in here via the constants:
  46. $this->_securitySalt = CONFIG_SECURITY_SALT;
  47. $this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL;
  48. }
  49. private function _processXmlResponse($url)
  50. {
  51. /*
  52. A private utility method used by other public methods to process XML responses.
  53. */
  54. if (extension_loaded('curl')) {
  55. $ch = curl_init() or die ( curl_error($ch) );
  56. $timeout = 10;
  57. curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
  58. curl_setopt( $ch, CURLOPT_URL, $url );
  59. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  60. curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  61. $data = curl_exec( $ch );
  62. curl_close( $ch );
  63. if($data)
  64. return (new SimpleXMLElement($data));
  65. else
  66. return false;
  67. }
  68. return (simplexml_load_file($url));
  69. }
  70. private function _requiredParam($param) {
  71. /* Process required params and throw errors if we don't get values */
  72. if ((isset($param)) && ($param != '')) {
  73. return $param;
  74. }
  75. elseif (!isset($param)) {
  76. throw new Exception('Missing parameter.');
  77. }
  78. else {
  79. throw new Exception(''.$param.' is required.');
  80. }
  81. }
  82. private function _optionalParam($param) {
  83. /* Pass most optional params through as set value, or set to '' */
  84. /* Don't know if we'll use this one, but let's build it in case. */
  85. if ((isset($param)) && ($param != '')) {
  86. return $param;
  87. }
  88. else {
  89. $param = '';
  90. return $param;
  91. }
  92. }
  93. /* __________________ BBB ADMINISTRATION METHODS _________________ */
  94. /* The methods in the following section support the following categories of the BBB API:
  95. -- create
  96. -- join
  97. -- end
  98. */
  99. public function getCreateMeetingUrl($creationParams) {
  100. /*
  101. USAGE:
  102. (see $creationParams array in createMeetingArray method.)
  103. */
  104. $this->_meetingId = $this->_requiredParam($creationParams['meetingId']);
  105. $this->_meetingName = $this->_requiredParam($creationParams['meetingName']);
  106. // Set up the basic creation URL:
  107. $creationUrl = $this->_bbbServerBaseUrl."api/create?";
  108. // Add params:
  109. $params =
  110. 'name='.urlencode($this->_meetingName).
  111. '&meetingID='.urlencode($this->_meetingId).
  112. '&attendeePW='.urlencode($creationParams['attendeePw']).
  113. '&moderatorPW='.urlencode($creationParams['moderatorPw']).
  114. '&dialNumber='.urlencode($creationParams['dialNumber']).
  115. '&voiceBridge='.urlencode($creationParams['voiceBridge']).
  116. '&webVoice='.urlencode($creationParams['webVoice']).
  117. '&logoutURL='.urlencode($creationParams['logoutUrl']).
  118. '&maxParticipants='.urlencode($creationParams['maxParticipants']).
  119. '&record='.urlencode($creationParams['record']).
  120. '&duration='.urlencode($creationParams['duration']);
  121. //'&meta_category='.urlencode($creationParams['meta_category']);
  122. $welcomeMessage = $creationParams['welcomeMsg'];
  123. if(trim($welcomeMessage))
  124. $params .= '&welcome='.urlencode($welcomeMessage);
  125. // Return the complete URL:
  126. return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
  127. }
  128. public function createMeetingWithXmlResponseArray($creationParams)
  129. {
  130. /*
  131. USAGE:
  132. $creationParams = array(
  133. 'name' => 'Meeting Name', -- A name for the meeting (or username)
  134. 'meetingId' => '1234', -- A unique id for the meeting
  135. 'attendeePw' => 'ap', -- Set to 'ap' and use 'ap' to join = no user pass required.
  136. 'moderatorPw' => 'mp', -- Set to 'mp' and use 'mp' to join = no user pass required.
  137. 'welcomeMsg' => '', -- ''= use default. Change to customize.
  138. 'dialNumber' => '', -- The main number to call into. Optional.
  139. 'voiceBridge' => '', -- 5 digits PIN to join voice. Required.
  140. 'webVoice' => '', -- Alphanumeric to join voice. Optional.
  141. 'logoutUrl' => '', -- Default in bigbluebutton.properties. Optional.
  142. 'maxParticipants' => '-1', -- Optional. -1 = unlimitted. Not supported in BBB. [number]
  143. 'record' => 'false', -- New. 'true' will tell BBB to record the meeting.
  144. 'duration' => '0', -- Default = 0 which means no set duration in minutes. [number]
  145. 'meta_category' => '', -- Use to pass additional info to BBB server. See API docs to enable.
  146. );
  147. */
  148. $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
  149. if ($xml) {
  150. if ($xml->meetingID) {
  151. return array(
  152. 'returncode' => $xml->returncode->__toString(),
  153. 'message' => $xml->message->__toString(),
  154. 'messageKey' => $xml->messageKey->__toString(),
  155. 'meetingId' => $xml->meetingID->__toString(),
  156. 'attendeePw' => $xml->attendeePW->__toString(),
  157. 'moderatorPw' => $xml->moderatorPW->__toString(),
  158. 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(),
  159. 'createTime' => $xml->createTime->__toString(),
  160. 'internalMeetingID' => $xml->internalMeetingID->__toString()
  161. );
  162. } else {
  163. return array(
  164. 'returncode' => $xml->returncode->__toString(),
  165. 'message' => $xml->message->__toString(),
  166. 'messageKey' => $xml->messageKey->__toString(),
  167. );
  168. }
  169. } else {
  170. return null;
  171. }
  172. }
  173. public function getJoinMeetingURL($joinParams) {
  174. /*
  175. NOTE: At this point, we don't use a corresponding joinMeetingWithXmlResponse here because the API
  176. doesn't respond on success, but you can still code that method if you need it. Or, you can take the URL
  177. that's returned from this method and simply send your users off to that URL in your code.
  178. USAGE:
  179. $joinParams = array(
  180. 'meetingId' => '1234', -- REQUIRED - A unique id for the meeting
  181. 'username' => 'Jane Doe', -- REQUIRED - The name that will display for the user in the meeting
  182. 'password' => 'ap', -- REQUIRED - The attendee or moderator password, depending on what's passed here
  183. 'createTime' => '', -- OPTIONAL - string. Leave blank ('') unless you set this correctly.
  184. 'userID' => '', -- OPTIONAL - string
  185. 'webVoiceConf' => '' -- OPTIONAL - string
  186. );
  187. */
  188. $this->_meetingId = $this->_requiredParam($joinParams['meetingId']);
  189. $this->_username = $this->_requiredParam($joinParams['username']);
  190. $this->_password = $this->_requiredParam($joinParams['password']);
  191. // Establish the basic join URL:
  192. $joinUrl = $this->_bbbServerBaseUrl."api/join?";
  193. // Add parameters to the URL:
  194. $params =
  195. 'meetingID='.urlencode($this->_meetingId).
  196. '&fullName='.urlencode($this->_username).
  197. '&password='.urlencode($this->_password).
  198. '&userID='.urlencode($joinParams['userID']).
  199. '&webVoiceConf='.urlencode($joinParams['webVoiceConf']);
  200. // Only use createTime if we really want to use it. If it's '', then don't pass it:
  201. if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) {
  202. $params .= '&createTime='.urlencode($joinParams['createTime']);
  203. }
  204. if (isset($joinParams['interface']) && (int) $joinParams['interface'] === BBBPlugin::INTERFACE_HTML5) {
  205. $bbbHost = api_remove_trailing_slash(CONFIG_SERVER_URL_WITH_PROTOCOL);
  206. $params .= '&redirectClient=true&clientURL='.$bbbHost.'/html5client/join';
  207. }
  208. // Return the URL:
  209. $url = $joinUrl.$params.'&checksum='.sha1('join'.$params.$this->_securitySalt);
  210. return $url;
  211. }
  212. public function getEndMeetingURL($endParams) {
  213. /* USAGE:
  214. $endParams = array (
  215. 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting
  216. 'password' => 'mp' -- REQUIRED - The moderator password for the meeting
  217. );
  218. */
  219. $this->_meetingId = $this->_requiredParam($endParams['meetingId']);
  220. $this->_password = $this->_requiredParam($endParams['password']);
  221. $endUrl = $this->_bbbServerBaseUrl."api/end?";
  222. $params =
  223. 'meetingID='.urlencode($this->_meetingId).
  224. '&password='.urlencode($this->_password);
  225. return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt));
  226. }
  227. public function endMeetingWithXmlResponseArray($endParams) {
  228. /* USAGE:
  229. $endParams = array (
  230. 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting
  231. 'password' => 'mp' -- REQUIRED - The moderator password for the meeting
  232. );
  233. */
  234. $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams));
  235. if ($xml) {
  236. return array(
  237. 'returncode' => $xml->returncode->__toString(),
  238. 'message' => $xml->message->__toString(),
  239. 'messageKey' => $xml->messageKey->__toString()
  240. );
  241. }
  242. else {
  243. return null;
  244. }
  245. }
  246. /* __________________ BBB MONITORING METHODS _________________ */
  247. /* The methods in the following section support the following categories of the BBB API:
  248. -- isMeetingRunning
  249. -- getMeetings
  250. -- getMeetingInfo
  251. */
  252. public function getIsMeetingRunningUrl($meetingId) {
  253. /* USAGE:
  254. $meetingId = '1234' -- REQUIRED - The unique id for the meeting
  255. */
  256. $this->_meetingId = $this->_requiredParam($meetingId);
  257. $runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?";
  258. $params =
  259. 'meetingID='.urlencode($this->_meetingId);
  260. return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt));
  261. }
  262. public function isMeetingRunningWithXmlResponseArray($meetingId) {
  263. /* USAGE:
  264. $meetingId = '1234' -- REQUIRED - The unique id for the meeting
  265. */
  266. $xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId));
  267. if($xml) {
  268. return array(
  269. 'returncode' => $xml->returncode->__toString(),
  270. 'running' => $xml->running->__toString() // -- Returns true/false.
  271. );
  272. }
  273. else {
  274. return null;
  275. }
  276. }
  277. public function getGetMeetingsUrl() {
  278. /* Simply formulate the getMeetings URL
  279. We do this in a separate function so we have the option to just get this
  280. URL and print it if we want for some reason.
  281. */
  282. $getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt);
  283. return $getMeetingsUrl;
  284. }
  285. public function getMeetingsWithXmlResponseArray() {
  286. /* USAGE:
  287. We don't need to pass any parameters with this one, so we just send the query URL off to BBB
  288. and then handle the results that we get in the XML response.
  289. */
  290. $xml = $this->_processXmlResponse($this->getGetMeetingsUrl());
  291. if($xml) {
  292. // If we don't get a success code, stop processing and return just the returncode:
  293. if ($xml->returncode != 'SUCCESS') {
  294. $result = array(
  295. 'returncode' => $xml->returncode->__toString()
  296. );
  297. return $result;
  298. }
  299. elseif ($xml->messageKey == 'noMeetings') {
  300. /* No meetings on server, so return just this info: */
  301. $result = array(
  302. 'returncode' => $xml->returncode->__toString(),
  303. 'messageKey' => $xml->messageKey->__toString(),
  304. 'message' => $xml->message->__toString()
  305. );
  306. return $result;
  307. }
  308. else {
  309. // In this case, we have success and meetings. First return general response:
  310. $result = array(
  311. 'returncode' => $xml->returncode->__toString(),
  312. 'messageKey' => $xml->messageKey->__toString(),
  313. 'message' => $xml->message->__toString()
  314. );
  315. // Then interate through meeting results and return them as part of the array:
  316. foreach ($xml->meetings->meeting as $m) {
  317. $result[] = array(
  318. 'meetingId' => $m->meetingID->__toString(),
  319. 'meetingName' => $m->meetingName->__toString(),
  320. 'createTime' => $m->createTime->__toString(),
  321. 'attendeePw' => $m->attendeePW->__toString(),
  322. 'moderatorPw' => $m->moderatorPW->__toString(),
  323. 'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded->__toString(),
  324. 'running' => $m->running->__toString()
  325. );
  326. }
  327. return $result;
  328. }
  329. }
  330. else {
  331. return null;
  332. }
  333. }
  334. public function getMeetingInfoUrl($infoParams) {
  335. /* USAGE:
  336. $infoParams = array(
  337. 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting
  338. 'password' => 'mp' -- REQUIRED - The moderator password for the meeting
  339. );
  340. */
  341. $this->_meetingId = $this->_requiredParam($infoParams['meetingId']);
  342. $this->_password = $this->_requiredParam($infoParams['password']);
  343. $infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?";
  344. $params =
  345. 'meetingID='.urlencode($this->_meetingId).
  346. '&password='.urlencode($this->_password);
  347. return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt));
  348. }
  349. public function getMeetingInfoWithXmlResponseArray($infoParams) {
  350. /* USAGE:
  351. $infoParams = array(
  352. 'meetingId' => '1234', -- REQUIRED - The unique id for the meeting
  353. 'password' => 'mp' -- REQUIRED - The moderator password for the meeting
  354. );
  355. */
  356. $xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams));
  357. if($xml) {
  358. // If we don't get a success code or messageKey, find out why:
  359. if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
  360. $result = array(
  361. 'returncode' => $xml->returncode->__toString(),
  362. 'messageKey' => $xml->messageKey->__toString(),
  363. 'message' => $xml->message->__toString()
  364. );
  365. return $result;
  366. } else {
  367. // In this case, we have success and meeting info:
  368. $result = array(
  369. 'returncode' => $xml->returncode->__toString(),
  370. 'meetingName' => $xml->meetingName->__toString(),
  371. 'meetingId' => $xml->meetingID->__toString(),
  372. 'createTime' => $xml->createTime->__toString(),
  373. 'voiceBridge' => $xml->voiceBridge->__toString(),
  374. 'attendeePw' => $xml->attendeePW->__toString(),
  375. 'moderatorPw' => $xml->moderatorPW->__toString(),
  376. 'running' => $xml->running->__toString(),
  377. 'recording' => $xml->recording->__toString(),
  378. 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(),
  379. 'startTime' => $xml->startTime->__toString(),
  380. 'endTime' => $xml->endTime->__toString(),
  381. 'participantCount' => $xml->participantCount->__toString(),
  382. 'maxUsers' => $xml->maxUsers->__toString(),
  383. 'moderatorCount' => $xml->moderatorCount->__toString(),
  384. 'internalMeetingID' => $xml->internalMeetingID->__toString()
  385. );
  386. // Then interate through attendee results and return them as part of the array:
  387. foreach ($xml->attendees->attendee as $a) {
  388. $result[] = array(
  389. 'userId' => $a->userID->__toString(),
  390. 'fullName' => $a->fullName->__toString(),
  391. 'role' => $a->role->__toString()
  392. );
  393. }
  394. return $result;
  395. }
  396. }
  397. else {
  398. return null;
  399. }
  400. }
  401. /* __________________ BBB RECORDING METHODS _________________ */
  402. /* The methods in the following section support the following categories of the BBB API:
  403. -- getRecordings
  404. -- publishRecordings
  405. -- deleteRecordings
  406. */
  407. public function getRecordingsUrl($recordingParams) {
  408. /* USAGE:
  409. $recordingParams = array(
  410. 'meetingId' => '1234', -- OPTIONAL - comma separate if multiple ids
  411. );
  412. */
  413. $recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?";
  414. $params = 'meetingID='.urlencode($recordingParams['meetingId']);
  415. return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt));
  416. }
  417. public function getRecordingsWithXmlResponseArray($recordingParams) {
  418. /* USAGE:
  419. $recordingParams = array(
  420. 'meetingId' => '1234', -- OPTIONAL - comma separate if multiple ids
  421. );
  422. NOTE: 'duration' DOES work when creating a meeting, so if you set duration
  423. when creating a meeting, it will kick users out after the duration. Should
  424. probably be required in user code when 'recording' is set to true.
  425. */
  426. $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams));
  427. if($xml) {
  428. // If we don't get a success code or messageKey, find out why:
  429. if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
  430. $result = array(
  431. 'returncode' => $xml->returncode->__toString(),
  432. 'messageKey' => $xml->messageKey->__toString(),
  433. 'message' => $xml->message->__toString()
  434. );
  435. return $result;
  436. }
  437. else {
  438. // In this case, we have success and recording info:
  439. $result = array(
  440. 'returncode' => $xml->returncode->__toString(),
  441. 'messageKey' => $xml->messageKey->__toString(),
  442. 'message' => $xml->message->__toString()
  443. );
  444. foreach ($xml->recordings->recording as $r) {
  445. $result[] = array(
  446. 'recordId' => $r->recordID->__toString(),
  447. 'meetingId' => $r->meetingID->__toString(),
  448. 'name' => $r->name->__toString(),
  449. 'published' => $r->published->__toString(),
  450. 'startTime' => $r->startTime->__toString(),
  451. 'endTime' => $r->endTime->__toString(),
  452. 'playbackFormatType' => $r->playback->format->type->__toString(),
  453. 'playbackFormatUrl' => $r->playback->format->url->__toString(),
  454. 'playbackFormatLength' => $r->playback->format->length->__toString(),
  455. 'metadataTitle' => $r->metadata->title->__toString(),
  456. 'metadataSubject' => $r->metadata->subject->__toString(),
  457. 'metadataDescription' => $r->metadata->description->__toString(),
  458. 'metadataCreator' => $r->metadata->creator->__toString(),
  459. 'metadataContributor' => $r->metadata->contributor->__toString(),
  460. 'metadataLanguage' => $r->metadata->language->__toString(),
  461. // Add more here as needed for your app depending on your
  462. // use of metadata when creating recordings.
  463. );
  464. }
  465. return $result;
  466. }
  467. }
  468. else {
  469. return null;
  470. }
  471. }
  472. /**
  473. * @param $array recordingParams
  474. *
  475. * @return array|null
  476. */
  477. public function getRecordings($recordingParams)
  478. {
  479. /* USAGE:
  480. $recordingParams = array(
  481. 'meetingId' => '1234', -- OPTIONAL - comma separate if multiple ids
  482. );
  483. NOTE: 'duration' DOES work when creating a meeting, so if you set duration
  484. when creating a meeting, it will kick users out after the duration. Should
  485. probably be required in user code when 'recording' is set to true.
  486. */
  487. $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams));
  488. if($xml) {
  489. // If we don't get a success code or messageKey, find out why:
  490. if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
  491. $result = array(
  492. 'returncode' => $xml->returncode->__toString(),
  493. 'messageKey' => $xml->messageKey->__toString(),
  494. 'message' => $xml->message->__toString()
  495. );
  496. return $result;
  497. }
  498. else {
  499. // In this case, we have success and recording info:
  500. $result = array(
  501. 'returncode' => $xml->returncode->__toString(),
  502. 'messageKey' => $xml->messageKey->__toString(),
  503. 'message' => $xml->message->__toString()
  504. );
  505. $result['records'] = [];
  506. if (!empty($xml->recordings->recording)) {
  507. foreach ($xml->recordings->recording as $r) {
  508. $result['records'][] = array(
  509. 'recordId' => $r->recordID->__toString(),
  510. 'meetingId' => $r->meetingID->__toString(),
  511. 'name' => $r->name->__toString(),
  512. 'published' => $r->published->__toString(),
  513. 'startTime' => $r->startTime->__toString(),
  514. 'endTime' => $r->endTime->__toString(),
  515. 'playbackFormatType' => $r->playback->format->type->__toString(),
  516. 'playbackFormatUrl' => $r->playback->format->url->__toString(),
  517. 'playbackFormatLength' => $r->playback->format->length->__toString(),
  518. 'metadataTitle' => $r->metadata->title->__toString(),
  519. 'metadataSubject' => $r->metadata->subject->__toString(),
  520. 'metadataDescription' => $r->metadata->description->__toString(),
  521. 'metadataCreator' => $r->metadata->creator->__toString(),
  522. 'metadataContributor' => $r->metadata->contributor->__toString(),
  523. 'metadataLanguage' => $r->metadata->language->__toString(),
  524. );
  525. }
  526. }
  527. return $result;
  528. }
  529. }
  530. return null;
  531. }
  532. public function getPublishRecordingsUrl($recordingParams) {
  533. /* USAGE:
  534. $recordingParams = array(
  535. 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids
  536. 'publish' => 'true', -- REQUIRED - boolean: true/false
  537. );
  538. */
  539. $recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?";
  540. $params =
  541. 'recordID='.urlencode($recordingParams['recordId']).
  542. '&publish='.urlencode($recordingParams['publish']);
  543. return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt));
  544. }
  545. public function publishRecordingsWithXmlResponseArray($recordingParams) {
  546. /* USAGE:
  547. $recordingParams = array(
  548. 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids
  549. 'publish' => 'true', -- REQUIRED - boolean: true/false
  550. );
  551. */
  552. $xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams));
  553. if($xml) {
  554. return array(
  555. 'returncode' => $xml->returncode->__toString(),
  556. 'published' => $xml->published->__toString() // -- Returns true/false.
  557. );
  558. }
  559. else {
  560. return null;
  561. }
  562. }
  563. public function getDeleteRecordingsUrl($recordingParams) {
  564. /* USAGE:
  565. $recordingParams = array(
  566. 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids
  567. );
  568. */
  569. $recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?";
  570. $params =
  571. 'recordID='.urlencode($recordingParams['recordId']);
  572. return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt));
  573. }
  574. public function deleteRecordingsWithXmlResponseArray($recordingParams) {
  575. /* USAGE:
  576. $recordingParams = array(
  577. 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids
  578. );
  579. */
  580. $xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams));
  581. if($xml) {
  582. return array(
  583. 'returncode' => $xml->returncode->__toString(),
  584. 'deleted' => $xml->deleted->__toString() // -- Returns true/false.
  585. );
  586. }
  587. else {
  588. return null;
  589. }
  590. }
  591. /** USAGE:
  592. * $recordingParams = array(
  593. * 'recordId' => '1234', -- REQUIRED - comma separate if multiple ids
  594. * );
  595. */
  596. public function generateRecording($recordingParams)
  597. {
  598. if (empty($recordingParams)) {
  599. return false;
  600. }
  601. $recordingsUrl = $this->_bbbServerBaseUrl.'../demo/regenerateRecord.jsp?';
  602. $params = 'recordID='.urlencode($recordingParams['recordId']);
  603. $url = $recordingsUrl.$params.'&checksum='.sha1('regenerateRecord'.$params.$this->_securitySalt);
  604. $ch = curl_init() or die ( curl_error($ch) );
  605. $timeout = 10;
  606. curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
  607. curl_setopt( $ch, CURLOPT_URL, $url );
  608. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  609. curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  610. $data = curl_exec( $ch );
  611. curl_close( $ch );
  612. return true;
  613. }
  614. }