1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016-2023 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; |
22
|
|
|
|
23
|
|
|
use BigBlueButton\Core\ApiMethod; |
24
|
|
|
use BigBlueButton\Exceptions\BadResponseException; |
25
|
|
|
use BigBlueButton\Parameters\CreateMeetingParameters; |
26
|
|
|
use BigBlueButton\Parameters\DeleteRecordingsParameters; |
27
|
|
|
use BigBlueButton\Parameters\EndMeetingParameters; |
28
|
|
|
use BigBlueButton\Parameters\GetMeetingInfoParameters; |
29
|
|
|
use BigBlueButton\Parameters\GetRecordingsParameters; |
30
|
|
|
use BigBlueButton\Parameters\GetRecordingTextTracksParameters; |
31
|
|
|
use BigBlueButton\Parameters\HooksCreateParameters; |
32
|
|
|
use BigBlueButton\Parameters\HooksDestroyParameters; |
33
|
|
|
use BigBlueButton\Parameters\InsertDocumentParameters; |
34
|
|
|
use BigBlueButton\Parameters\IsMeetingRunningParameters; |
35
|
|
|
use BigBlueButton\Parameters\JoinMeetingParameters; |
36
|
|
|
use BigBlueButton\Parameters\PublishRecordingsParameters; |
37
|
|
|
use BigBlueButton\Parameters\PutRecordingTextTrackParameters; |
38
|
|
|
use BigBlueButton\Parameters\UpdateRecordingsParameters; |
39
|
|
|
use BigBlueButton\Responses\ApiVersionResponse; |
40
|
|
|
use BigBlueButton\Responses\CreateMeetingResponse; |
41
|
|
|
use BigBlueButton\Responses\DeleteRecordingsResponse; |
42
|
|
|
use BigBlueButton\Responses\EndMeetingResponse; |
43
|
|
|
use BigBlueButton\Responses\GetMeetingInfoResponse; |
44
|
|
|
use BigBlueButton\Responses\GetMeetingsResponse; |
45
|
|
|
use BigBlueButton\Responses\GetRecordingsResponse; |
46
|
|
|
use BigBlueButton\Responses\GetRecordingTextTracksResponseResponse; |
|
|
|
|
47
|
|
|
use BigBlueButton\Responses\HooksCreateResponse; |
48
|
|
|
use BigBlueButton\Responses\HooksDestroyResponse; |
49
|
|
|
use BigBlueButton\Responses\HooksListResponse; |
50
|
|
|
use BigBlueButton\Responses\InsertDocumentResponse; |
51
|
|
|
use BigBlueButton\Responses\IsMeetingRunningResponse; |
52
|
|
|
use BigBlueButton\Responses\JoinMeetingResponse; |
53
|
|
|
use BigBlueButton\Responses\PublishRecordingsResponse; |
54
|
|
|
use BigBlueButton\Responses\PutRecordingTextTrackResponse; |
55
|
|
|
use BigBlueButton\Responses\UpdateRecordingsResponse; |
56
|
|
|
use BigBlueButton\Util\UrlBuilder; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Class BigBlueButton. |
60
|
|
|
*/ |
61
|
|
|
class BigBlueButton |
62
|
|
|
{ |
63
|
|
|
protected $securitySecret; |
64
|
|
|
protected $bbbServerBaseUrl; |
65
|
|
|
protected $urlBuilder; |
66
|
|
|
protected $jSessionId; |
67
|
|
|
protected $curlopts = []; |
68
|
|
|
protected $timeOut = 10; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* BigBlueButton constructor. |
72
|
|
|
* |
73
|
|
|
* @param null $baseUrl |
|
|
|
|
74
|
|
|
* @param null $secret |
|
|
|
|
75
|
|
|
* @param null|mixed $opts |
76
|
|
|
*/ |
77
|
|
|
public function __construct($baseUrl = null, $secret = null, $opts = null) |
78
|
|
|
{ |
79
|
|
|
// Keeping backward compatibility with older deployed versions |
80
|
|
|
// BBB_SECRET is the new variable name and have higher priority against the old named BBB_SECURITY_SALT |
81
|
|
|
$this->securitySecret = $secret ?: getenv('BBB_SECRET') ?: getenv('BBB_SECURITY_SALT'); |
|
|
|
|
82
|
|
|
$this->bbbServerBaseUrl = $baseUrl ?: getenv('BBB_SERVER_BASE_URL'); |
|
|
|
|
83
|
|
|
$this->urlBuilder = new UrlBuilder($this->securitySecret, $this->bbbServerBaseUrl); |
84
|
|
|
$this->curlopts = $opts['curl'] ?? []; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return ApiVersionResponse |
89
|
|
|
* |
90
|
|
|
* @throws \RuntimeException |
91
|
|
|
*/ |
92
|
|
|
public function getApiVersion() |
93
|
|
|
{ |
94
|
|
|
$xml = $this->processXmlResponse($this->urlBuilder->buildUrl()); |
95
|
|
|
|
96
|
|
|
return new ApiVersionResponse($xml); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
// __________________ BBB ADMINISTRATION METHODS _________________ |
100
|
|
|
/* The methods in the following section support the following categories of the BBB API: |
101
|
|
|
-- create |
102
|
|
|
-- join |
103
|
|
|
-- end |
104
|
|
|
-- insertDocument |
105
|
|
|
*/ |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param CreateMeetingParameters $createMeetingParams |
109
|
|
|
* |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
public function getCreateMeetingUrl($createMeetingParams) |
113
|
|
|
{ |
114
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::CREATE, $createMeetingParams->getHTTPQuery()); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param CreateMeetingParameters $createMeetingParams |
119
|
|
|
* |
120
|
|
|
* @return CreateMeetingResponse |
121
|
|
|
* |
122
|
|
|
* @throws \RuntimeException |
123
|
|
|
*/ |
124
|
|
|
public function createMeeting($createMeetingParams) |
125
|
|
|
{ |
126
|
|
|
$xml = $this->processXmlResponse($this->getCreateMeetingUrl($createMeetingParams), $createMeetingParams->getPresentationsAsXML()); |
|
|
|
|
127
|
|
|
|
128
|
|
|
return new CreateMeetingResponse($xml); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param $joinMeetingParams JoinMeetingParameters |
133
|
|
|
* |
134
|
|
|
* @return string |
135
|
|
|
*/ |
136
|
|
|
public function getJoinMeetingURL($joinMeetingParams) |
137
|
|
|
{ |
138
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::JOIN, $joinMeetingParams->getHTTPQuery()); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param $joinMeetingParams JoinMeetingParameters |
143
|
|
|
* |
144
|
|
|
* @return JoinMeetingResponse |
145
|
|
|
* |
146
|
|
|
* @throws \RuntimeException |
147
|
|
|
*/ |
148
|
|
|
public function joinMeeting($joinMeetingParams) |
149
|
|
|
{ |
150
|
|
|
$xml = $this->processXmlResponse($this->getJoinMeetingURL($joinMeetingParams)); |
151
|
|
|
|
152
|
|
|
return new JoinMeetingResponse($xml); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param $endParams EndMeetingParameters |
157
|
|
|
* |
158
|
|
|
* @return string |
159
|
|
|
*/ |
160
|
|
|
public function getEndMeetingURL($endParams) |
161
|
|
|
{ |
162
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::END, $endParams->getHTTPQuery()); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param $endParams EndMeetingParameters |
167
|
|
|
* |
168
|
|
|
* @return EndMeetingResponse |
169
|
|
|
* |
170
|
|
|
* @throws \RuntimeException |
171
|
|
|
* |
172
|
|
|
* */ |
173
|
|
|
public function endMeeting($endParams) |
174
|
|
|
{ |
175
|
|
|
$xml = $this->processXmlResponse($this->getEndMeetingURL($endParams)); |
176
|
|
|
|
177
|
|
|
return new EndMeetingResponse($xml); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param CreateMeetingParameters $createMeetingParams |
182
|
|
|
* |
183
|
|
|
* @return string |
184
|
|
|
*/ |
185
|
|
|
public function getInsertDocumentUrl($createMeetingParams) |
186
|
|
|
{ |
187
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::INSERT_DOCUMENT, $createMeetingParams->getHTTPQuery()); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @param $insertDocumentParams InsertDocumentParameters |
192
|
|
|
* |
193
|
|
|
* @return InsertDocumentResponse |
194
|
|
|
* |
195
|
|
|
* @throws \RuntimeException |
196
|
|
|
*/ |
197
|
|
|
public function insertDocument($insertDocumentParams) |
198
|
|
|
{ |
199
|
|
|
$xml = $this->processXmlResponse($this->getInsertDocumentUrl($insertDocumentParams), $insertDocumentParams->getPresentationsAsXML()); |
200
|
|
|
|
201
|
|
|
return new CreateMeetingResponse($xml); |
|
|
|
|
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
// __________________ BBB MONITORING METHODS _________________ |
205
|
|
|
/* The methods in the following section support the following categories of the BBB API: |
206
|
|
|
-- isMeetingRunning |
207
|
|
|
-- getMeetings |
208
|
|
|
-- getMeetingInfo |
209
|
|
|
*/ |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @param $meetingParams IsMeetingRunningParameters |
213
|
|
|
* |
214
|
|
|
* @return string |
215
|
|
|
*/ |
216
|
|
|
public function getIsMeetingRunningUrl($meetingParams) |
217
|
|
|
{ |
218
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::IS_MEETING_RUNNING, $meetingParams->getHTTPQuery()); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @param mixed $meetingParams |
223
|
|
|
* |
224
|
|
|
* @return IsMeetingRunningResponse |
225
|
|
|
* |
226
|
|
|
* @throws \RuntimeException |
227
|
|
|
*/ |
228
|
|
|
public function isMeetingRunning($meetingParams) |
229
|
|
|
{ |
230
|
|
|
$xml = $this->processXmlResponse($this->getIsMeetingRunningUrl($meetingParams)); |
231
|
|
|
|
232
|
|
|
return new IsMeetingRunningResponse($xml); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return string |
237
|
|
|
*/ |
238
|
|
|
public function getMeetingsUrl() |
239
|
|
|
{ |
240
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::GET_MEETINGS); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @return GetMeetingsResponse |
245
|
|
|
* |
246
|
|
|
* @throws \RuntimeException |
247
|
|
|
*/ |
248
|
|
|
public function getMeetings() |
249
|
|
|
{ |
250
|
|
|
$xml = $this->processXmlResponse($this->getMeetingsUrl()); |
251
|
|
|
|
252
|
|
|
return new GetMeetingsResponse($xml); |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @param $meetingParams GetMeetingInfoParameters |
257
|
|
|
* |
258
|
|
|
* @return string |
259
|
|
|
*/ |
260
|
|
|
public function getMeetingInfoUrl($meetingParams) |
261
|
|
|
{ |
262
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::GET_MEETING_INFO, $meetingParams->getHTTPQuery()); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* @param $meetingParams GetMeetingInfoParameters |
267
|
|
|
* |
268
|
|
|
* @throws \RuntimeException |
269
|
|
|
*/ |
270
|
|
|
public function getMeetingInfo($meetingParams) |
271
|
|
|
{ |
272
|
|
|
$xml = $this->processXmlResponse($this->getMeetingInfoUrl($meetingParams)); |
273
|
|
|
|
274
|
|
|
return new GetMeetingInfoResponse($xml); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
// __________________ BBB RECORDING METHODS _________________ |
278
|
|
|
/* The methods in the following section support the following categories of the BBB API: |
279
|
|
|
-- getRecordings |
280
|
|
|
-- publishRecordings |
281
|
|
|
-- deleteRecordings |
282
|
|
|
*/ |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @param $recordingsParams GetRecordingsParameters |
286
|
|
|
* |
287
|
|
|
* @return string |
288
|
|
|
*/ |
289
|
|
|
public function getRecordingsUrl($recordingsParams) |
290
|
|
|
{ |
291
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::GET_RECORDINGS, $recordingsParams->getHTTPQuery()); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @param mixed $recordingParams |
296
|
|
|
* |
297
|
|
|
* @throws \RuntimeException |
298
|
|
|
*/ |
299
|
|
|
public function getRecordings($recordingParams) |
300
|
|
|
{ |
301
|
|
|
$xml = $this->processXmlResponse($this->getRecordingsUrl($recordingParams)); |
302
|
|
|
|
303
|
|
|
return new GetRecordingsResponse($xml); |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* @param $recordingParams PublishRecordingsParameters |
308
|
|
|
* |
309
|
|
|
* @return string |
310
|
|
|
*/ |
311
|
|
|
public function getPublishRecordingsUrl($recordingParams) |
312
|
|
|
{ |
313
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::PUBLISH_RECORDINGS, $recordingParams->getHTTPQuery()); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* @param $recordingParams PublishRecordingsParameters |
318
|
|
|
* |
319
|
|
|
* @throws \RuntimeException |
320
|
|
|
*/ |
321
|
|
|
public function publishRecordings($recordingParams) |
322
|
|
|
{ |
323
|
|
|
$xml = $this->processXmlResponse($this->getPublishRecordingsUrl($recordingParams)); |
324
|
|
|
|
325
|
|
|
return new PublishRecordingsResponse($xml); |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* @param $recordingParams DeleteRecordingsParameters |
330
|
|
|
* |
331
|
|
|
* @return string |
332
|
|
|
*/ |
333
|
|
|
public function getDeleteRecordingsUrl($recordingParams) |
334
|
|
|
{ |
335
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::DELETE_RECORDINGS, $recordingParams->getHTTPQuery()); |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
/** |
339
|
|
|
* @param $recordingParams DeleteRecordingsParameters |
340
|
|
|
* |
341
|
|
|
* @return DeleteRecordingsResponse |
342
|
|
|
* |
343
|
|
|
* @throws \RuntimeException |
344
|
|
|
*/ |
345
|
|
|
public function deleteRecordings($recordingParams) |
346
|
|
|
{ |
347
|
|
|
$xml = $this->processXmlResponse($this->getDeleteRecordingsUrl($recordingParams)); |
348
|
|
|
|
349
|
|
|
return new DeleteRecordingsResponse($xml); |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* @param $recordingParams UpdateRecordingsParameters |
354
|
|
|
* |
355
|
|
|
* @return string |
356
|
|
|
*/ |
357
|
|
|
public function getUpdateRecordingsUrl($recordingParams) |
358
|
|
|
{ |
359
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::UPDATE_RECORDINGS, $recordingParams->getHTTPQuery()); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
/** |
363
|
|
|
* @param $recordingParams UpdateRecordingsParameters |
364
|
|
|
* |
365
|
|
|
* @throws \RuntimeException |
366
|
|
|
*/ |
367
|
|
|
public function updateRecordings($recordingParams) |
368
|
|
|
{ |
369
|
|
|
$xml = $this->processXmlResponse($this->getUpdateRecordingsUrl($recordingParams)); |
370
|
|
|
|
371
|
|
|
return new UpdateRecordingsResponse($xml); |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* @param $getRecordingTextTracksParameters GetRecordingTextTracksParameters |
376
|
|
|
* |
377
|
|
|
* @return string |
378
|
|
|
*/ |
379
|
|
|
public function getRecordingTextTracksUrl($getRecordingTextTracksParameters) |
380
|
|
|
{ |
381
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::GET_RECORDING_TEXT_TRACKS, $getRecordingTextTracksParameters->getHTTPQuery()); |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* @param $getRecordingTextTracksParams GetRecordingTextTracksParameters |
386
|
|
|
* |
387
|
|
|
* @return GetRecordingTextTracksResponseResponse |
388
|
|
|
*/ |
389
|
|
|
public function getRecordingTextTracks($getRecordingTextTracksParams) |
390
|
|
|
{ |
391
|
|
|
$json = $this->processJsonResponse($this->getRecordingTextTracksUrl($getRecordingTextTracksParams)); |
392
|
|
|
|
393
|
|
|
return new GetRecordingTextTracksResponseResponse($json); |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* @param $putRecordingTextTrackParams PutRecordingTextTrackParameters |
398
|
|
|
* |
399
|
|
|
* @return string |
400
|
|
|
*/ |
401
|
|
|
public function getPutRecordingTextTrackUrl(PutRecordingTextTrackParameters $putRecordingTextTrackParams) |
402
|
|
|
{ |
403
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::PUT_RECORDING_TEXT_TRACK, $putRecordingTextTrackParams->getHTTPQuery()); |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* @param $putRecordingTextTrackParams PutRecordingTextTrackParameters |
408
|
|
|
* |
409
|
|
|
* @return PutRecordingTextTrackResponse |
410
|
|
|
*/ |
411
|
|
|
public function putRecordingTextTrack($putRecordingTextTrackParams) |
412
|
|
|
{ |
413
|
|
|
$json = $this->processJsonResponse($this->getPutRecordingTextTrackUrl($putRecordingTextTrackParams)); |
414
|
|
|
|
415
|
|
|
return new PutRecordingTextTrackResponse($json); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
// ____________________ WEB HOOKS METHODS ___________________ |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* @param $hookCreateParams HooksCreateParameters |
422
|
|
|
* |
423
|
|
|
* @return string |
424
|
|
|
*/ |
425
|
|
|
public function getHooksCreateUrl($hookCreateParams) |
426
|
|
|
{ |
427
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::HOOKS_CREATE, $hookCreateParams->getHTTPQuery()); |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* @param mixed $hookCreateParams |
432
|
|
|
* |
433
|
|
|
* @return HooksCreateResponse |
434
|
|
|
*/ |
435
|
|
|
public function hooksCreate($hookCreateParams) |
436
|
|
|
{ |
437
|
|
|
$xml = $this->processXmlResponse($this->getHooksCreateUrl($hookCreateParams)); |
438
|
|
|
|
439
|
|
|
return new HooksCreateResponse($xml); |
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* @return string |
444
|
|
|
*/ |
445
|
|
|
public function getHooksListUrl() |
446
|
|
|
{ |
447
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::HOOKS_LIST); |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* @return HooksListResponse |
452
|
|
|
*/ |
453
|
|
|
public function hooksList() |
454
|
|
|
{ |
455
|
|
|
$xml = $this->processXmlResponse($this->getHooksListUrl()); |
456
|
|
|
|
457
|
|
|
return new HooksListResponse($xml); |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
/** |
461
|
|
|
* @param $hooksDestroyParams HooksDestroyParameters |
462
|
|
|
* |
463
|
|
|
* @return string |
464
|
|
|
*/ |
465
|
|
|
public function getHooksDestroyUrl($hooksDestroyParams) |
466
|
|
|
{ |
467
|
|
|
return $this->urlBuilder->buildUrl(ApiMethod::HOOKS_DESTROY, $hooksDestroyParams->getHTTPQuery()); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* @param mixed $hooksDestroyParams |
472
|
|
|
* |
473
|
|
|
* @return HooksDestroyResponse |
474
|
|
|
*/ |
475
|
|
|
public function hooksDestroy($hooksDestroyParams) |
476
|
|
|
{ |
477
|
|
|
$xml = $this->processXmlResponse($this->getHooksDestroyUrl($hooksDestroyParams)); |
478
|
|
|
|
479
|
|
|
return new HooksDestroyResponse($xml); |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
// ____________________ SPECIAL METHODS ___________________ |
483
|
|
|
/** |
484
|
|
|
* @return string |
485
|
|
|
*/ |
486
|
|
|
public function getJSessionId() |
487
|
|
|
{ |
488
|
|
|
return $this->jSessionId; |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
/** |
492
|
|
|
* @param string $jSessionId |
493
|
|
|
*/ |
494
|
|
|
public function setJSessionId($jSessionId) |
495
|
|
|
{ |
496
|
|
|
$this->jSessionId = $jSessionId; |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* @param array $curlopts |
501
|
|
|
*/ |
502
|
|
|
public function setCurlOpts($curlopts) |
503
|
|
|
{ |
504
|
|
|
$this->curlopts = $curlopts; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* Set Curl Timeout (Optional), Default 10 Seconds. |
509
|
|
|
* |
510
|
|
|
* @param int $TimeOutInSeconds |
511
|
|
|
* |
512
|
|
|
* @return static |
513
|
|
|
*/ |
514
|
|
|
public function setTimeOut($TimeOutInSeconds) |
515
|
|
|
{ |
516
|
|
|
$this->timeOut = $TimeOutInSeconds; |
517
|
|
|
|
518
|
|
|
return $this; |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
/** |
522
|
|
|
* Public accessor for buildUrl. |
523
|
|
|
* |
524
|
|
|
* @param string $method |
525
|
|
|
* @param string $params |
526
|
|
|
* @param bool $append |
527
|
|
|
* |
528
|
|
|
* @return string |
529
|
|
|
*/ |
530
|
|
|
public function buildUrl($method = '', $params = '', $append = true) |
531
|
|
|
{ |
532
|
|
|
return $this->urlBuilder->buildUrl($method, $params, $append); |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
// ____________________ INTERNAL CLASS METHODS ___________________ |
536
|
|
|
|
537
|
|
|
/** |
538
|
|
|
* A private utility method used by other public methods to request HTTP responses. |
539
|
|
|
* |
540
|
|
|
* @param string $url |
541
|
|
|
* @param string $payload |
542
|
|
|
* @param string $contentType |
543
|
|
|
* |
544
|
|
|
* @return string |
545
|
|
|
* |
546
|
|
|
* @throws \RuntimeException |
547
|
|
|
*/ |
548
|
|
|
private function sendRequest($url, $payload = '', $contentType = 'application/xml') |
549
|
|
|
{ |
550
|
|
|
if (extension_loaded('curl')) { |
551
|
|
|
$ch = curl_init(); |
552
|
|
|
if (!$ch) { |
553
|
|
|
throw new \RuntimeException('Unhandled curl error: ' . curl_error($ch)); |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
// Needed to store the JSESSIONID |
557
|
|
|
$cookiefile = tmpfile(); |
558
|
|
|
$cookiefilepath = stream_get_meta_data($cookiefile)['uri']; |
559
|
|
|
|
560
|
|
|
foreach ($this->curlopts as $opt => $value) { |
561
|
|
|
curl_setopt($ch, $opt, $value); |
562
|
|
|
} |
563
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); |
564
|
|
|
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8'); |
565
|
|
|
curl_setopt($ch, CURLOPT_URL, $url); |
566
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
567
|
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
568
|
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeOut); |
569
|
|
|
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefilepath); |
570
|
|
|
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefilepath); |
571
|
|
|
if (!empty($payload)) { |
572
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0); |
573
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); |
574
|
|
|
curl_setopt($ch, CURLOPT_POST, 1); |
575
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); |
576
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
577
|
|
|
'Content-type: ' . $contentType, |
578
|
|
|
'Content-length: ' . mb_strlen($payload), |
579
|
|
|
]); |
580
|
|
|
} |
581
|
|
|
$data = curl_exec($ch); |
582
|
|
|
if (false === $data) { |
583
|
|
|
throw new \RuntimeException('Unhandled curl error: ' . curl_error($ch)); |
584
|
|
|
} |
585
|
|
|
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
586
|
|
|
if ($httpcode < 200 || $httpcode >= 300) { |
587
|
|
|
throw new BadResponseException('Bad response, HTTP code: ' . $httpcode); |
588
|
|
|
} |
589
|
|
|
curl_close($ch); |
590
|
|
|
unset($ch); |
591
|
|
|
|
592
|
|
|
$cookies = file_get_contents($cookiefilepath); |
593
|
|
|
if (false !== mb_strpos($cookies, 'JSESSIONID')) { |
594
|
|
|
preg_match('/(?:JSESSIONID\s*)(?<JSESSIONID>.*)/', $cookies, $output_array); |
595
|
|
|
$this->setJSessionId($output_array['JSESSIONID']); |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
return $data; |
|
|
|
|
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
throw new \RuntimeException('Post XML data set but curl PHP module is not installed or not enabled.'); |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
/** |
605
|
|
|
* A private utility method used by other public methods to process XML responses. |
606
|
|
|
* |
607
|
|
|
* @param string $url |
608
|
|
|
* @param string $payload |
609
|
|
|
* @param string $contentType |
610
|
|
|
* |
611
|
|
|
* @return \SimpleXMLElement |
612
|
|
|
*/ |
613
|
|
|
private function processXmlResponse($url, $payload = '', $contentType = 'application/xml') |
614
|
|
|
{ |
615
|
|
|
return new \SimpleXMLElement($this->sendRequest($url, $payload, $contentType)); |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* A private utility method used by other public methods to process json responses. |
620
|
|
|
*/ |
621
|
|
|
private function processJsonResponse(string $url, string $payload = '', string $contentType = 'application/json') |
622
|
|
|
{ |
623
|
|
|
return $this->sendRequest($url, $payload, $contentType); |
624
|
|
|
} |
625
|
|
|
} |
626
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths