Skip to content

Commit f37dd93

Browse files
committed
Add support for webhooks.
1 parent 90d5d62 commit f37dd93

21 files changed

+791
-0
lines changed

src/BigBlueButton.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
use BigBlueButton\Parameters\EndMeetingParameters;
2525
use BigBlueButton\Parameters\GetMeetingInfoParameters;
2626
use BigBlueButton\Parameters\GetRecordingsParameters;
27+
use BigBlueButton\Parameters\HooksCreateParameters;
28+
use BigBlueButton\Parameters\HooksDestroyParameters;
2729
use BigBlueButton\Parameters\IsMeetingRunningParameters;
2830
use BigBlueButton\Parameters\JoinMeetingParameters;
2931
use BigBlueButton\Parameters\PublishRecordingsParameters;
@@ -36,6 +38,9 @@
3638
use BigBlueButton\Responses\GetMeetingInfoResponse;
3739
use BigBlueButton\Responses\GetMeetingsResponse;
3840
use BigBlueButton\Responses\GetRecordingsResponse;
41+
use BigBlueButton\Responses\HooksCreateResponse;
42+
use BigBlueButton\Responses\HooksDestroyResponse;
43+
use BigBlueButton\Responses\HooksListResponse;
3944
use BigBlueButton\Responses\IsMeetingRunningResponse;
4045
use BigBlueButton\Responses\JoinMeetingResponse;
4146
use BigBlueButton\Responses\PublishRecordingsResponse;
@@ -351,6 +356,66 @@ public function updateRecordings($recordingParams)
351356
return new UpdateRecordingsResponse($xml);
352357
}
353358

359+
/* ____________________ WEB HOOKS METHODS ___________________ */
360+
361+
/**
362+
* @param $hookCreateParams HooksCreateParameters
363+
* @return string
364+
*/
365+
public function getHooksCreateUrl($hookCreateParams)
366+
{
367+
return $this->urlBuilder->buildUrl(ApiMethod::HOOKS_CREATE, $hookCreateParams->getHTTPQuery());
368+
}
369+
370+
/**
371+
* @param $hookCreateParams
372+
* @return HooksCreateResponse
373+
*/
374+
public function hooksCreate($hookCreateParams)
375+
{
376+
$xml = $this->processXmlResponse($this->getHooksCreateUrl($hookCreateParams));
377+
378+
return new HooksCreateResponse($xml);
379+
}
380+
381+
/**
382+
* @return string
383+
*/
384+
public function getHooksListUrl()
385+
{
386+
return $this->urlBuilder->buildUrl(ApiMethod::HOOKS_LIST);
387+
}
388+
389+
/**
390+
* @return HooksListResponse
391+
*/
392+
public function hooksList()
393+
{
394+
$xml = $this->processXmlResponse($this->getHooksListUrl());
395+
396+
return new HooksListResponse($xml);
397+
}
398+
399+
/**
400+
* @param $hooksDestroyParams HooksDestroyParameters
401+
* @return string
402+
*/
403+
public function getHooksDestroyUrl($hooksDestroyParams)
404+
{
405+
return $this->urlBuilder->buildUrl(ApiMethod::HOOKS_DESTROY, $hooksDestroyParams->getHTTPQuery());
406+
}
407+
408+
/**
409+
* @param $hooksDestroyParams
410+
* @return HooksDestroyResponse
411+
*/
412+
public function hooksDestroy($hooksDestroyParams)
413+
{
414+
$xml = $this->processXmlResponse($this->getHooksDestroyUrl($hooksDestroyParams));
415+
416+
return new HooksDestroyResponse($xml);
417+
}
418+
354419
/* ____________________ SPECIAL METHODS ___________________ */
355420
/**
356421
* @return string

src/Core/ApiMethod.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,7 @@ abstract class ApiMethod
3535
const PUBLISH_RECORDINGS = 'publishRecordings';
3636
const DELETE_RECORDINGS = 'deleteRecordings';
3737
const UPDATE_RECORDINGS = 'updateRecordings';
38+
const HOOKS_CREATE = 'hooks/create';
39+
const HOOKS_LIST = 'hooks/list';
40+
const HOOKS_DESTROY = 'hooks/destroy';
3841
}

src/Core/Hook.php

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
3+
/**
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
namespace BigBlueButton\Core;
21+
22+
/**
23+
* Class Meeting
24+
* @package BigBlueButton\Core
25+
*/
26+
class Hook
27+
{
28+
29+
/**
30+
* @var \SimpleXMLElement
31+
*/
32+
protected $rawXml;
33+
34+
/**
35+
* @var string
36+
*/
37+
private $hookId;
38+
39+
/**
40+
* @var string
41+
*/
42+
private $meetingId;
43+
44+
/**
45+
* @var string
46+
*/
47+
private $callbackUrl;
48+
49+
/**
50+
* @var bool
51+
*/
52+
private $permanentHook;
53+
54+
/**
55+
* @var bool
56+
*/
57+
private $rawData;
58+
59+
/**
60+
* Meeting constructor.
61+
* @param $xml \SimpleXMLElement
62+
*/
63+
public function __construct($xml)
64+
{
65+
$this->rawXml = $xml;
66+
$this->hookId = (int) $xml->hookID->__toString();
67+
$this->callbackUrl = $xml->callbackURL->__toString();
68+
$this->meetingId = $xml->meetingID->__toString();
69+
$this->permanentHook = $xml->permanentHook->__toString() === 'true';
70+
$this->rawData = $xml->rawData->__toString() === 'true';
71+
}
72+
73+
/**
74+
* @return string
75+
*/
76+
public function getHookId()
77+
{
78+
return $this->hookId;
79+
}
80+
81+
/**
82+
* @return string
83+
*/
84+
public function getMeetingId()
85+
{
86+
return $this->meetingId;
87+
}
88+
89+
/**
90+
* @return string
91+
*/
92+
public function getCallbackUrl()
93+
{
94+
return $this->callbackUrl;
95+
}
96+
97+
/**
98+
* @return bool
99+
*/
100+
public function isPermanentHook()
101+
{
102+
return $this->permanentHook;
103+
}
104+
105+
/**
106+
* @return bool
107+
*/
108+
public function hasRawData()
109+
{
110+
return $this->rawData;
111+
}
112+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
/**
3+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
4+
*
5+
* Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below).
6+
*
7+
* This program is free software; you can redistribute it and/or modify it under the
8+
* terms of the GNU Lesser General Public License as published by the Free Software
9+
* Foundation; either version 3.0 of the License, or (at your option) any later
10+
* version.
11+
*
12+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License along
17+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
namespace BigBlueButton\Parameters;
20+
21+
class HooksCreateParameters extends BaseParameters
22+
{
23+
24+
/**
25+
* @var string
26+
*/
27+
private $callbackUrl;
28+
29+
/**
30+
* @var string
31+
*/
32+
private $meetingId;
33+
34+
/**
35+
* @var string
36+
*/
37+
private $getRaw;
38+
39+
/**
40+
* HooksCreateParameters constructor.
41+
*
42+
* @param $callbackUrl
43+
*/
44+
public function __construct($callbackUrl)
45+
{
46+
$this->callbackUrl = $callbackUrl;
47+
}
48+
49+
/**
50+
* @return string
51+
*/
52+
public function getCallbackUrl()
53+
{
54+
return $this->callbackUrl;
55+
}
56+
57+
/**
58+
* @param string $callbackUrl
59+
* @return HooksCreateParameters
60+
*/
61+
public function setCallbackUrl($callbackUrl)
62+
{
63+
$this->callbackUrl = $callbackUrl;
64+
65+
return $this;
66+
}
67+
68+
/**
69+
* @return string
70+
*/
71+
public function getMeetingId()
72+
{
73+
return $this->meetingId;
74+
}
75+
76+
/**
77+
* @param string $meetingId
78+
* @return HooksCreateParameters
79+
*/
80+
public function setMeetingId($meetingId)
81+
{
82+
$this->meetingId = $meetingId;
83+
84+
return $this;
85+
}
86+
87+
/**
88+
* @return string
89+
*/
90+
public function getRaw()
91+
{
92+
return $this->getRaw;
93+
}
94+
95+
/**
96+
* @param string $getRaw
97+
* @return HooksCreateParameters
98+
*/
99+
public function setGetRaw($getRaw)
100+
{
101+
$this->getRaw = $getRaw;
102+
103+
return $this;
104+
}
105+
106+
/**
107+
* @return string
108+
*/
109+
public function getHTTPQuery()
110+
{
111+
$queries = [
112+
'callbackURL' => $this->callbackUrl,
113+
'meetingID' => $this->meetingId,
114+
'getRaw' => $this->getRaw
115+
];
116+
117+
return $this->buildHTTPQuery($queries);
118+
}
119+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
4+
*
5+
* Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below).
6+
*
7+
* This program is free software; you can redistribute it and/or modify it under the
8+
* terms of the GNU Lesser General Public License as published by the Free Software
9+
* Foundation; either version 3.0 of the License, or (at your option) any later
10+
* version.
11+
*
12+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License along
17+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
namespace BigBlueButton\Parameters;
20+
21+
class HooksDestroyParameters extends BaseParameters
22+
{
23+
24+
/**
25+
* @var string
26+
*/
27+
private $hookId;
28+
29+
/**
30+
* HooksDestroyParameters constructor.
31+
*
32+
* @param $hookId
33+
*/
34+
public function __construct($hookId)
35+
{
36+
$this->hookId = $hookId;
37+
}
38+
39+
/**
40+
* @return string
41+
*/
42+
public function getHookId()
43+
{
44+
return $this->hookId;
45+
}
46+
47+
/**
48+
* @param string $hookId
49+
* @return HooksDestroyParameters
50+
*/
51+
public function setHookId($hookId)
52+
{
53+
$this->hookId = $hookId;
54+
55+
return $this;
56+
}
57+
58+
/**
59+
* @return string
60+
*/
61+
public function getHTTPQuery()
62+
{
63+
$queries = [
64+
'hookID' => $this->hookId
65+
];
66+
67+
return $this->buildHTTPQuery($queries);
68+
}
69+
}

0 commit comments

Comments
 (0)