-
Notifications
You must be signed in to change notification settings - Fork 0
/
_bbbapi.php
52 lines (52 loc) · 1.37 KB
/
_bbbapi.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
<?php
// Max Base
// _bbbapi.php
// https://github.com/BaseMax/PHPBigBlueButtonAPI
include "_phpnet.php";
$host="https://maxbase.org/bigbluebutton/"; // you need to change domain
$key="********"; // you need to change secret key
function buildQuery($values) {
$query="";
foreach($values as $k=>$v) {
$query.=$k."=".urlencode($v)."&";
}
$query=rtrim($query, "&");
return $query;
}
function call($method, $query=[]) {
global $host;
global $key;
$url=buildQuery($query);
$url="$url&checksum=".sha1($method . $url . $key);
$link=$host."api/".$method."?".$url;
print "[Request] $link\n";
$res=get($link);
if(is_bool($res[0])) {
// return "";
return [false, [], ""];
}
return array_merge(parseOutput($res[0]), [$res[1]]);
}
function parseOutput($response) {
$result=[];
$response=trim($response);
if($response == "") {
return [false, $result];
// return $result;
}
preg_match('/<response>(?<content>.*?)<\/response>/si', $response, $data);
if(isset($data["content"]) and $data["content"] != "") {
preg_match_all('/<(?<key>[^\>]+)>(?<value>[^\<]+|)<\/(?<keyEnd>[^\>]+)>/i', $response, $matches);
foreach($matches["key"] as $i=>$key) {
$value=$matches["value"][$i];
$result[$key]=$value;
}
}
if(isset($result["returncode"]) and $result["returncode"] == "SUCCESS") { // FAILED
return [true, $result];
}
else {
return [false, $result];
}
// return $result;
}