From 8c83e1a0d35f84ab4827a3e0de113d51e43ef25b Mon Sep 17 00:00:00 2001
From: xaker1 <admin@prolan.pw>
Date: Sat, 3 May 2014 22:29:59 +0400
Subject: [PATCH] Add send XML in createMeetingWithXmlResponseArray

---
 labs/bbb-api-php/includes/bbb-api.php | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/labs/bbb-api-php/includes/bbb-api.php b/labs/bbb-api-php/includes/bbb-api.php
index 93bdec919a..311a7e7201 100644
--- a/labs/bbb-api-php/includes/bbb-api.php
+++ b/labs/bbb-api-php/includes/bbb-api.php
@@ -36,6 +36,8 @@ Versions:
 					- Now using Zend coding, naming and style conventions
 					- Refactored methods to accept standardized parameters & match BBB API structure
 					    -- See included samples for usage examples
+   1.4  --  Updated by xaker1
+                    (email : admin [a t ] xaker1 DOT ru)
 */
 
 /* _______________________________________________________________________*/
@@ -60,7 +62,7 @@ class BigBlueButton {
 		$this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;		
 	}
 	
-	private function _processXmlResponse($url){
+	private function _processXmlResponse($url, $xml = ''){
 	/* 
 	A private utility method used by other public methods to process XML responses.
 	*/
@@ -71,6 +73,16 @@ class BigBlueButton {
 			curl_setopt( $ch, CURLOPT_URL, $url );
 			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
 			curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+			if(!empty($xml)){
+				curl_setopt($ch, CURLOPT_HEADER, 0);
+				curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
+				curl_setopt($ch, CURLOPT_POST, 1);
+				curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
+				curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+                                       'Content-type: application/xml',
+                                       'Content-length: ' . strlen($xml)
+                                     ));
+			}
 			$data = curl_exec( $ch );
 			curl_close( $ch );
 
@@ -79,6 +91,9 @@ class BigBlueButton {
 			else
 				return false;
 		}
+		if(!empty($xml))
+			throw new Exception('Set xml, but curl does not installed.');
+
 		return (simplexml_load_file($url));	
 	}
 	
@@ -144,7 +159,7 @@ class BigBlueButton {
 		return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
 	}
 			
-	public function createMeetingWithXmlResponseArray($creationParams) {
+	public function createMeetingWithXmlResponseArray($creationParams, $xml = '') {
 		/*
 		USAGE: 
 		$creationParams = array(
@@ -162,8 +177,9 @@ class BigBlueButton {
 			'duration' => '0', 			-- Default = 0 which means no set duration in minutes. [number]
 			'meta_category' => '', 		-- Use to pass additional info to BBB server. See API docs to enable.
 		);
+		$xml = '';				-- Use to pass additional xml to BBB server. Example, use to Preupload Slides. See API docs. 
 		*/
-		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
+		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams), $xml);
 
 		if($xml) {
 			if($xml->meetingID) 
-- 
GitLab