setConfigXMLAnchor via php

198 views
Skip to first unread message

Павел Викторович

unread,
Mar 27, 2017, 1:28:58 AM3/27/17
to BigBlueButton-Setup
Hello! Installed bbb 1.1beta, I'm trying to use the setConfigXML function via a call to the php script. I get an error all the time: "configXMLChecksumError: request did not pass the checksum security check." All I do according to the API. I tried to use an example from this post: "https://groups.google.com/d/msg/bigbluebutton-dev/gc9jTg0Zli8..". The same story. Maybe because I'm using php7.0? Any changes need to be made in the script from the post? I'm not really into php. When everything was written on Delphi - everything was shaping well. On php in any. I will be glad to any advice. I can not use the official BigBlueButton API for PHP, I do not understand how to make a script using this library correctly. Sorry for my english - I use google translator.

HostBBB.com

unread,
Mar 27, 2017, 8:22:07 AM3/27/17
to BigBlueButton-Setup

Hi,  you need to use POST not GET calls, and your params need to be URLENCODED... those are the 2 most common issues with dynamic configs.

I would suggest posting your code snippet in the google bigbluebutton-dev group.   More likely to get  some technical help there on the api if we can see the code.

regards,
Stephen

Павел Викторович

unread,
Mar 27, 2017, 9:17:35 AM3/27/17
to BigBlueButton-Setup
Thanks for your reply! Here is the code I use. I seem to fulfill all the requirements, but I get an error.

meetingID='sample_id';
$SALT = 'sample_salt';

$configXml = getConfigXml('http://192.168.100.12/', 'config'); //here I receive xml which I want to use
$configXml =$configXml->asXML(); //
$configToken = setConfigXmlForMeeting($meetingID,$configXml,$sault,'http://192.168.100.12/bigbluebutton/');

function setConfigXmlForMeeting( $meetingID, $xmlConfig, $SALT, $URL ) {
 $url_join = $URL."api/setConfigXML.xml?";
 $baseString = 'configXML='.urlencode(encodeURI($xmlConfig)).'&meetingID='.urlencode($meetingID);
 $checksum = sha1('setConfigXML'.$baseString.$SALT);
 $params = $baseString.'&checksum='.$checksum;
 
 $xml = bbb_wrap_simplexml_load_file_params($url_join, $params, 'application/x-www-form-urlencoded; charset=UTF-8');
 
 if( $xml && $xml->returncode == 'SUCCESS' ) {
 return ( $xml->configToken );
 } 
 else if( $xml ) {
 return ( (string)$xml->messageKey.' : '.(string)$xml->message );
 }
 else {
 return ('Unable to fetch URL '.$url_join.$params );
 }
}


function encodeURI($url) {
 $unescaped = array(
 '%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~',
 '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')'
 );
 $reserved = array(
 '%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':',
 '%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$'
 );
 $score = array(
 '%23'=>'#'
 );
 return strtr(urlencode($url), array_merge($reserved,$unescaped,$score));
}

function bbb_wrap_simplexml_load_file_params($url, $params, $contentType){
   if (extension_loaded('curl')) 
   {
      $ch = curl_init() or die ( curl_error() );
      $timeout = 10;
      curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);  
      curl_setopt( $ch, CURLOPT_URL, $url );
      curl_setopt( $ch, CURLOPT_POST, true);
      curl_setopt( $ch, CURLOPT_POSTFIELDS, $params);
      curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
      curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
      curl_setopt( $ch, CURLOPT_HTTPHEADER, array("Content-type: ".$contentType)); // application/x-www-form-urlencoded; charset=UTF-8"));
      $data = curl_exec( $ch );
      curl_close( $ch );       
      if($data)
                {
                        $tr=new SimpleXMLElement($data);
                        var_dump($tr);
         return ($tr);
                }
                        else
         return false;  
   }
   return null;   
}

I can not write to the development team, I did not accept the request to join the group. 
I tried to exclude the function "encodeURI". It seems to me a problem somewhere in a line of a line "$ configXml-> asXML ()" .... Probably some additional conversions for received xml are necessary?

(Text is written using google translator)


понедельник, 27 марта 2017 г., 15:22:07 UTC+3 пользователь HostBBB.com написал:

Павел Викторович

unread,
Mar 28, 2017, 8:35:16 AM3/28/17
to BigBlueButton-Setup
I solved the problem by using the official library (https://github.com/bigbluebutton/bigbluebutton-api-php).
The code is about this:

<?php
use BigBlueButton\BigBlueButton;
use BigBlueButton\Parameters\JoinMeetingParameters;
use BigBlueButton\Parameters\SetConfigXMLParameters;

include
('Parameters/JoinMeetingParameters.php');
include
('BigBlueButton.php');
include
('Parameters/SetConfigXMLParameters.php');

$bbb
= new BigBlueButton($SALT, $URL);

$burl
= parse_url($URL, PHP_URL_SCHEME).'://'.parse_url($URL, PHP_URL_HOST).'/';
$configXml
= getConfigXml($burl, 'configMCU');

$setConfParams
= new SetConfigXMLParameters($meetingID);
$setConfParams
->setMeetingId($meetingID);
$setConfParams
->setRawXml($configXml);
$test
= $bbb->setConfigXML($setConfParams);

 $joinMeetingParams
= new JoinMeetingParameters($meetingID, $userName, $PW); // $moderator_password for moderator
 $joinMeetingParams
->setRedirect(true);
 $joinMeetingParams
->setConfigToken($test->getToken());

 $url
= $bbb->getJoinMeetingURL($joinMeetingParams);
return $url;

function getConfigXml($BASE_URL, $configName)
 
{
 $result
= bbb_load_file( $BASE_URL.'client/conf/'.$configName.'.xml');

 
if(is_null($result))
 
{
 
return 'Error : file not found on server.';
 
}
 
else
 
{
 $fr
=new SimpleXMLElement($result);
 
// var_dump($fr);
 
return $fr;
 
}
 
}

 
function bbb_load_file($url){

 
if (extension_loaded('curl')) {
 $ch
= curl_init() or die ( curl_error() );
 $timeout
= 10;
 curl_setopt
( $ch, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt
( $ch, CURLOPT_URL, $url );

 curl_setopt
( $ch, CURLOPT_RETURNTRANSFER, 1 );
 curl_setopt
( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);

 $data
= curl_exec( $ch );

 $isError
= (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 404);
 curl_close
( $ch );

 
if($data && ! $isError)
 
{ //var_dump($data);
 
return $data;
 
}
 
else
 
return null;
 
}
 
return null;
 
}
?>

In the file SetConfigXMLResponse.php correct the line:
public function getToken()
{
 
return $this->rawXml->configToken->__toString();
}

 it was 'return $this->rawXml->Token->__toString();'

Ghazi TRIKI

unread,
Mar 28, 2017, 10:28:23 AM3/28/17
to BigBlueButton-Setup
Hello Павел,

Thank you for spotting the PHP API library issue. It wil get fixed and the documentation as well.

Ghazi
Reply all
Reply to author
Forward
0 new messages