1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016-2022 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
|
|
|
|
21
|
|
|
namespace BigBlueButton\Util; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class UrlBuilder. |
25
|
|
|
*/ |
26
|
|
|
class UrlBuilder |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $securitySalt; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
private $bbbServerBaseUrl; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* UrlBuilder constructor. |
40
|
|
|
* |
41
|
|
|
* @param $secret |
42
|
|
|
* @param $serverBaseUrl |
43
|
|
|
*/ |
44
|
|
|
public function __construct($secret, $serverBaseUrl) |
45
|
|
|
{ |
46
|
|
|
$this->securitySalt = $secret; |
47
|
|
|
$this->bbbServerBaseUrl = $serverBaseUrl; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Builds an API method URL that includes the url + params + its generated checksum. |
52
|
|
|
* |
53
|
|
|
* @param string $method |
54
|
|
|
* @param string $params |
55
|
|
|
* @param bool $append |
56
|
|
|
* |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function buildUrl($method = '', $params = '', $append = true) |
60
|
|
|
{ |
61
|
|
|
return $this->bbbServerBaseUrl . 'api/' . $method . ($append ? '?' . $this->buildQs($method, $params) : ''); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Builds a query string for an API method URL that includes the params + its generated checksum. |
66
|
|
|
* |
67
|
|
|
* @param string $method |
68
|
|
|
* @param string $params |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function buildQs($method = '', $params = '') |
73
|
|
|
{ |
74
|
|
|
return $params . '&checksum=' . sha1($method . $params . $this->securitySalt); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|