Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Connect to BBB API and return response.
- *
- * @param $params
- * Associative array of additional url parameters. See bbb_api_create().
- * @param $call
- * API call name. Possible values:
- * - 'create'
- * - 'isMeetingRunning'
- * - 'endMeeting'
- * - 'getMeetingInfo'
- * @todo: test for other API calls, see http://code.google.com/p/bigbluebutton/wiki/API#API_Calls
- *
- * @return
- * Response stdClass or FALSE if BBB service is not available at given url.
- */
- function bbb_api_call($params, $call) {
- $query_string = bbb_api_generate_querystring($params, $call);
- $url = BIGBLUEBUTTON_BASE_URL . '/api/' . $call . '?' . $query_string;
- // Set options for the HTTP request.
- $options = array(
- 'method' => 'POST',
- // @todo: implement as a setting variable.
- 'timeout' => 5,
- );
- $result = drupal_http_request($url, $options);
- // If errors occured, return FALSE.
- if ($result->code != 200) {
- // Log error to watchdog.
- watchdog('bigbluebutton', 'BigBlueButton connection error. API call: %call <br/>Request URL: %url <br/>Result code: %code <br/>Result error: %error', array(
- '%call' => $call,
- '%url' => $url,
- '%code' => $result->code,
- '%error' => $result->error,
- ), WATCHDOG_DEBUG);
- return FALSE;
- }
- else {
- // If XML is available, process data.
- if (!empty($result->data)) {
- // Process XML string into SimpleXMLElement object.
- $xml = simplexml_load_string($result->data);
- // Process SimpleXMLElement object.
- $response = bbb_api_parse_response($xml);
- // Check if request was successful.
- if (isset($response->returncode) && $response->returncode == 'SUCCESS') {
- // Everything is fine.
- }
- else {
- // If errors occured, log them.
- if (isset($response->message)) {
- watchdog('bigbluebutton', '%message', array('%message' => $response->message), WATCHDOG_ERROR);
- }
- }
- return $response;
- }
- else {
- return FALSE;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement