| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Copyright (c) 2016 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; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use BigBlueButton\Core\ApiMethod; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use BigBlueButton\Parameters\CreateMeetingParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use BigBlueButton\Parameters\DeleteRecordingsParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use BigBlueButton\Parameters\EndMeetingParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use BigBlueButton\Parameters\GetMeetingInfoParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use BigBlueButton\Parameters\GetRecordingsParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use BigBlueButton\Parameters\IsMeetingRunningParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use BigBlueButton\Parameters\JoinMeetingParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use BigBlueButton\Parameters\PublishRecordingsParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use BigBlueButton\Responses\ApiVersionResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use BigBlueButton\Responses\CreateMeetingResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use BigBlueButton\Responses\DeleteRecordingsResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use BigBlueButton\Responses\EndMeetingResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use BigBlueButton\Responses\GetMeetingInfoResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use BigBlueButton\Responses\GetMeetingsResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | use BigBlueButton\Responses\GetRecordingsResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | use BigBlueButton\Responses\IsMeetingRunningResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | use BigBlueButton\Responses\PublishRecordingsResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | use BigBlueButton\Util\UrlBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | use SimpleXMLElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  * Class BigBlueButton | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  * @package BigBlueButton | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 45 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | class BigBlueButton | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |     private $securitySalt; | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |     private $bbbServerBaseUrl; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     private $urlBuilder; | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public function __construct() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->securitySalt     = $_SERVER['BBB_SECURITY_SALT']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->bbbServerBaseUrl = $_SERVER['BBB_SERVER_BASE_URL']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->urlBuilder       = new UrlBuilder($this->securitySalt, $this->bbbServerBaseUrl); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |      * @return ApiVersionResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |      * @throws \Exception | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function getApiVersion() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         return new ApiVersionResponse($this->processXmlResponse($this->urlBuilder->buildUrl())); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |     /* __________________ BBB ADMINISTRATION METHODS _________________ */ | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |     /* The methods in the following section support the following categories of the BBB API: | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |     -- create | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     -- join | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |     -- end | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |     */ | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |      * @param $createMeetingParams CreateMeetingParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     public function getCreateMeetingUrl($createMeetingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::CREATE, $createMeetingParams->getHTTPQuery()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |      * @param  CreateMeetingParameters $createMeetingParams | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |      * @return CreateMeetingResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |      * @throws \Exception | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     public function createMeeting($createMeetingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $xml = $this->processXmlResponse($this->getCreateMeetingUrl($createMeetingParams), $createMeetingParams->getPresentationsAsXML()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         return new CreateMeetingResponse($xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 96 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |      * @param $joinMeetingParams JoinMeetingParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     public function getJoinMeetingURL($joinMeetingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::JOIN, $joinMeetingParams->getHTTPQuery()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |      * @param $endParams EndMeetingParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     public function getEndMeetingURL($endParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::END, $endParams->getHTTPQuery()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |      * @param $endParams EndMeetingParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |      * @return EndMeetingResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     public function endMeeting($endParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $xml = $this->processXmlResponse($this->getEndMeetingURL($endParams)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         return new EndMeetingResponse($xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |     /* __________________ BBB MONITORING METHODS _________________ */ | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |     /* The methods in the following section support the following categories of the BBB API: | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |     -- isMeetingRunning | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |     -- getMeetings | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |     -- getMeetingInfo | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |     */ | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |      * @param $meetingParams IsMeetingRunningParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     public function getIsMeetingRunningUrl($meetingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::IS_MEETING_RUNNING, $meetingParams->getHTTPQuery()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 144 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  |      * @param $meetingParams | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |      * @return IsMeetingRunningResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |      * @throws \Exception | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     public function isMeetingRunning($meetingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         $xml = $this->processXmlResponse($this->getIsMeetingRunningUrl($meetingParams)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         return new IsMeetingRunningResponse($xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 156 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     public function getMeetingsUrl() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::GET_MEETINGS); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 164 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |      * @return GetMeetingsResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     public function getMeetings() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         $xml = $this->processXmlResponse($this->getMeetingsUrl()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         return new GetMeetingsResponse($xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 174 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  |      * @param $meetingParams GetMeetingInfoParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     public function getMeetingInfoUrl($meetingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::IS_MEETING_RUNNING, $meetingParams->getHTTPQuery()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 183 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |      * @param $meetingParams GetMeetingInfoParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  |      * @return GetMeetingInfoResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     public function getMeetingInfo($meetingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $xml = $this->processXmlResponse($this->getMeetingInfoUrl($meetingParams)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         return new GetMeetingInfoResponse($xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 194 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 196 |  |  |     /* __________________ BBB RECORDING METHODS _________________ */ | 
            
                                                                        
                            
            
                                    
            
            
                | 197 |  |  |     /* The methods in the following section support the following categories of the BBB API: | 
            
                                                                        
                            
            
                                    
            
            
                | 198 |  |  |     -- getRecordings | 
            
                                                                        
                            
            
                                    
            
            
                | 199 |  |  |     -- publishRecordings | 
            
                                                                        
                            
            
                                    
            
            
                | 200 |  |  |     -- deleteRecordings | 
            
                                                                        
                            
            
                                    
            
            
                | 201 |  |  |     */ | 
            
                                                                        
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 203 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  |      * @param $recordingsParams GetRecordingsParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 205 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 206 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     public function getRecordingsUrl($recordingsParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::GET_RECORDINGS, $recordingsParams->getHTTPQuery()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 210 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 212 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 213 |  |  |      * @param $recordingParams | 
            
                                                                        
                            
            
                                    
            
            
                | 214 |  |  |      * @return GetRecordingsResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 215 |  |  |      * @throws \Exception | 
            
                                                                        
                            
            
                                    
            
            
                | 216 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     public function getRecordings($recordingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         $xml = $this->processXmlResponse($this->getRecordingsUrl($recordingParams)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         return new GetRecordingsResponse($xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 222 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 224 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 225 |  |  |      * @param $recordingParams PublishRecordingsParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 226 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 227 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |     public function getPublishRecordingsUrl($recordingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::PUBLISH_RECORDINGS, $recordingParams->getHTTPQuery()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 231 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  |      * @param $recordingParams PublishRecordingsParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  |      * @return PublishRecordingsResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  |      * @throws \Exception | 
            
                                                                        
                            
            
                                    
            
            
                | 237 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     public function publishRecordings($recordingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         $xml = $this->processXmlResponse($this->getPublishRecordingsUrl($recordingParams)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         return new PublishRecordingsResponse($xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 243 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  |      * @param $recordingParams DeleteRecordingsParameters | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     public function deleteRecordingsUrl($recordingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         return $this->urlBuilder->buildUrl(ApiMethod::DELETE_RECORDINGS, $recordingParams->getHTTPQuery()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 252 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  |      * @param $recordingParams | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  |      * @return DeleteRecordingsResponse | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  |      * @throws \Exception | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |     public function deleteRecordings($recordingParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |         $xml = $this->processXmlResponse($this->deleteRecordingsUrl($recordingParams)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         return new DeleteRecordingsResponse($xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 264 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 265 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 266 |  |  |     /* ____________________ INTERNAL CLASS METHODS ___________________ */ | 
            
                                                                        
                            
            
                                    
            
            
                | 267 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 268 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 269 |  |  |      * A private utility method used by other public methods to process XML responses. | 
            
                                                                        
                            
            
                                    
            
            
                | 270 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 271 |  |  |      * @param $url | 
            
                                                                        
                            
            
                                    
            
            
                | 272 |  |  |      * @param  string                $xml | 
            
                                                                        
                            
            
                                    
            
            
                | 273 |  |  |      * @return bool|SimpleXMLElement | 
            
                                                                        
                            
            
                                    
            
            
                | 274 |  |  |      * @throws \Exception | 
            
                                                                        
                            
            
                                    
            
            
                | 275 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |     private function processXmlResponse($url, $xml = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         if (extension_loaded('curl')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |             $ch      = curl_init() or die(curl_error()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |             $timeout = 10; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |             curl_setopt($ch, CURLOPT_URL, $url); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |             if (!empty($xml)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |                 curl_setopt($ch, CURLOPT_HEADER, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |                 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                 curl_setopt($ch, CURLOPT_POST, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                 curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |                 curl_setopt($ch, CURLOPT_HTTPHEADER, [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |                     'Content-type: application/xml', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |                     'Content-length: ' . strlen($xml), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |                 ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |             $data = curl_exec($ch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |             curl_close($ch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |             if ($data) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |                 return new SimpleXMLElement($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                 return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |         if (!empty($xml)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |             throw new \Exception('Set xml, but curl does not installed.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |         return simplexml_load_file($url); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 313 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 314 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 315 |  |  |  | 
            
                        
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: