Keep up-to-date on the new APIs and SDKs, technical modifications and maintenance work.

How to develop a TYPO3 extension based on the Conference Call API

Jun 15th By: Alexander Kraskov

The conference call API is the most complex API of the Developer Garden portfolio. There is a total of 20 REST methods. You can create telephone conferences with up to 15 people using the API. There are ad-hoc conferences that start immediately as well as planned conferences. During a conference, for example, participants can be added or removed.AJAX technology is required to develop a good conference call plug-in.

In the previous article on sending SMS texts, we also showed you how a simple extension can be created. You can use the "Kickstarter" extension again, but this time – instead of the "/src/sendsms/ folder – you copy the "/src/conferencecall/" folder to the "lib" folder. You need the "jQuery" library for the AJAX functionality and also need to copy it in the "lib".

The second step is creating the "eId" script."eId" means "Extension Id" and this script can be called up with "www.example.com?eID=keyword". Calling up this script interrupts the normal rendering process, which is why the pure JSON or XML data can be output.

To register a new keyword, write it in "ext_localconf.php":

$TYPO3_CONF_VARS['FE']['eID_include']['conferencecall'] = 'EXT:conferencecall/pi1/tx_conferencecall_eId.php';

The keyword "conferencecall" is now connected to the script "tx_conferencecall_eId.php".

The file "tx_conferencecall_eId.php" does not need to contain any PHP classes, but only a simple script. At the beginning of the file, you write:

if (!defined ('PATH_typo3conf')) die ('Access denied.');

And add SDK:

require_once(dirname(__FILE__) . '/../lib/sdk/conferencecall/client/ConferenceCallClient.php');
require_once(dirname(__FILE__) . '/../lib/sdk/conferencecall/data/ConferenceCallStatusConstants.php');

The POST variable "command" will represent the SDK's functions."0" will mean CreatateConference(), "1" also means CreatateConference(), but only for the planned conferences and "2" calls up AddParticipant(), etc.

switch($_POST['command']) {
  case 0:
    // Creates Ad Hoc conference
    $createConferenceResponse = null;
    try {
      $createConferenceResponse = $client->createConference($_POST['ownerID'], $_POST['name'], $_POST['description'], null, null, $_POST['duration'], $_POST['joinConfirm'], null, null);
      if(!($createConferenceResponse->getStatus()->getStatusConstant() == ConferenceCallStatusConstants::SUCCESS)) {
        $errorMessage = $createConferenceResponse->getStatus()->getStatusDescriptionEnglish();
        throw new Exception($errorMessage);
      } else {
        $a = Array (
          'Status' => 1,
          'ConfId' => $createConferenceResponse->getConferenceId()
        );
      }
    }
catch(Exception $e) {
      $a = Array (
        'Status' => 0,
        'ConfId' => 0
      );
    }

    break;
}

Since the Telekom client is created in the eId script, the Developer Center login data (user name and password) must be transferred in this script.You can do this with a TYPO3 session. In the "main" function of the "tx_conferencecall_pi1.php" file, you write:

$GLOBALS['TSFE']->fe_user]->setKey('ses','dc_username', $username);
$GLOBALS['TSFE']->fe_user]->setKey('ses','dc_password', $password);
$GLOBALS['TSFE']->fe_user]->setKey('ses','dc_proxy', $proxy);
$GLOBALS['TSFE']->fe_user]->setKey('ses','dc_environment', $environment);
$GLOBALS['TSFE']->storeSessionData();

If the login data is saved in a FlexForm, write the following before the session is processed:

$this->pi_initPIflexform();
$username = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'DC_Login', 'sheet1');
$password = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'DC_Password', 'sheet1');
$proxy = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'Proxy', 'sheet1');
$env = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'Environment', 'sheet1');

You must then create your HTML forms for all functions. There is still one JS script missing that calls up the functions from the eId script. First, you add links to the jQuery and new JavaScript file to "tx_conferencecall_pi1.php".

$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= '<script src="' . t3lib_extMgm::siteRelPath($this->extKey) . 'lib/jquery.js" type="text/javascript" />';
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= '<script src="' . t3lib_extMgm::siteRelPath($this->extKey) . 'pi1/tx_conferencecall_pi1.js" />';

And then you write the implementation of the required functions to the "tx_conferencecall_pi1.js".

function confcall_newParticipantInTemplate() {
  jQuery.ajax({
    url: "index.php",
    type: "POST",
    data: {
        eID: "conferencecall",
        command: 3,
        confID: jQuery("#conf_id").val(),
        firstname: jQuery("#conf_firstname").val(),
        lastname: jQuery("#conf_lastname").val(),
        phonenumber: jQuery("#conf_phone").val(),
        email: jQuery("#conf_email").val()
      },
    dataType: "json",
    success: function(response) {
        if (response.Status == 1) {
          // The participant has been added 
        } else {
          // There is an error
        }
    }
,
    error: function(error) {
        // AJAX-Error
    }
  });
}

As an example, you can find the conference call extension, in which the API methods were already implemented, in the TYPO3 Extensions Repository and in the TYPO3 Forge.

Responses to “How to develop a TYPO3 extension based on the Conference Call API”

    No comments
Leave a Comment