我是 PHP 新手,正在尝试使用第三方代码,即 Big blue button api https://github.com/bigbluebutton/bigbluebutton/tree/master/labs/bbb-api-php
我尝试调用BigBlueButton->createMeeting()
如下所示的函数:
public function createMeeting($createMeetingParams, $xml = '')
{
$xml = $this->processXmlResponse($this
->getCreateMeetingURL($createMeetingParams), $xml);
//$xml is fine
return new CreateMeetingResponse($xml);
}
创建会议响应类
namespace BigBlueButton\Responses;
/**
* Class CreateMeetingResponse
* @package BigBlueButton\Responses
*/
class CreateMeetingResponse extends BaseResponse
{
/**
* @return string
*/
public function getMeetingId()
{
return $this->rawXml->meetingID->__toString();
}
/**
* @return string
*/
public function getAttendeePassword()
{
return $this->rawXml->attendeePW->__toString();
}
/**
* @return string
*/
public function getModeratorPassword()
{
return $this->rawXml->moderatorPW->__toString();
}
/**
* Creation timestamp.
*
* @return double
*/
public function getCreationTime()
{
return doubleval($this->rawXml->createTime);
}
/**
* @return int
*/
public function getVoiceBridge()
{
return intval($this->rawXml->voiceBridge);
}
/**
* @return string
*/
public function getDialNumber()
{
return $this->rawXml->dialNumber->__toString();
}
/**
* Creation date at the format "Sun Jan 17 18:20:07 EST 2016".
*
* @return string
*/
public function getCreationDate()
{
return $this->rawXml->createDate->__toString();
}
/**
* @return true
*/
public function hasUserJoined()
{
return $this->rawXml->hasUserJoined->__toString() == 'true';
}
/**
* @return int
*/
public function getDuration()
{
return intval($this->rawXml->duration);
}
/**
* @return bool
*/
public function hasBeenForciblyEnded()
{
return $this->rawXml->hasBeenForciblyEnded->__toString() == 'true';
}
/**
* @return string
*/
public function getMessageKey()
{
return $this->rawXml->messageKey->__toString();
}
/**
* @return string
*/
public function getMessage()
{
$this->rawXml->message->__toString();
}
}
BaseResponse 类
namespace BigBlueButton\Parameters;
/**
* Class BaseParameters.
*/
abstract class BaseParameters
{
/**
* @param $array
*
* @return string
*/
protected function buildHTTPQuery($array)
{
return http_build_query(array_filter($array));
}
/**
* @return string
*/
abstract public function getHTTPQuery();
}
现在,当我调用该BigBlueButton->createMeeting()
函数时,我期待一个可以编码为 json 的对象,但我得到的是这个(我在print_r()
这里使用过..):
BigBlueButton\Responses\CreateMeetingResponse Object
(
[rawXml:protected] => SimpleXMLElement Object
(
[returncode] => FAILED
[messageKey] => idNotUnique
[message] => A meeting already exists with that meeting ID. Please use a different meeting ID.
)
)
我不确定发生了什么,但我认为前缀命名空间' BigBlueButton\Responses\CreateMeetingResponse Object
'是问题所在。我想解析我在 php 中得到的 json 对象的响应,但不能
这是我尝试解析它的地方
function easymeet_create_meeting($id) {
// Create BBB object
$bbb = new BigBlueButton\BigBlueButton();
//creating meeting parameter
$meetingParas=new BigBlueButton\Parameters\CreateMeetingParameters('123456','sned');
//Creatign meeting
return json_encode($bbb->createMeeting($meetingParas));
///print_r($bbb->createMeeting($meetingParas)) give the xml response shown above
}