Is Indico Feed module available for global Drupal community?

Hi all,
I’d like to use feed to import contents in a Drupal website, outside CERN infrastructure.
Basically my question concern if the Indico Feed module is available globally or it is reserved to internal CERN purposes and it is possible to use it only in the website created inside CERN community.

I have to show in a website the list of indico events that my customer has been hosted in Indico

1 Like

Hey,

One can use the CERN indico feeds module but will have to do a few basic modifications for the use and also will have to work with the prerequisites of the module so as to ensure complete functionality for the same.

To summarise we do not recommend the use of this module outside of CERN since it has a few ongoing changes with the current version and it will be hard to maintain the compatibility outside the CERN infra.

I hope this helps.

Regards,
Prakhar

Dear Marzini

You can implement your own custom method of accessing INDICO events based on
https://docs.getindico.io/en/stable/api/
For example:


function _build_indico_request($path, $params, $api_key = null, $secret_key = null, 
                              $only_public = false, $persistent = false) {

   if ($api_key) {
      $params['apikey'] = $api_key;
   }

   if ($only_public) {
      $params['onlypublic'] = 'yes';
   }

   if ($secret_key) {
      if (!$persistent) {
         $params['timestamp'] = time();
      }
      uksort($params, 'strcasecmp');
      $url = $path . '?' . http_build_query($params, "", "&");
      $params['signature'] = hash_hmac('sha1', $url, $secret_key);
   }

   if (!$params) {
      return $path;
   }

   return   $path . '?' . http_build_query($params, "", "&");
}

function _alice_indico_get_events_json($category) {
   set_time_limit ( 360 );
   //category is mandotory field
   //keys is to access to private indico
   $config = \Drupal::configFactory()->getEditable('alice_indico.settings');
   $category = $config->get('category');
   $api_key = $config->get('api_key');
   $secret_key = $config->get('secret_key');

   $PATH = '/export/categ/' . $category . '.json';  
   // let retrive also tomorrow event, so in case of failure
   // we will have 48h of cached events
   $PARAMS = array(
         'from'=>'today',
         'to'=>'tomorrow'
   );

   $request = "https://indico.cern.ch" . 
               _build_indico_request($PATH, $PARAMS, $API_KEY, $SECRET_KEY);
               
   // if something is not working remove the @ to see the warnings
   
   $calendar = @file_get_contents($request);  
            
   if ($calendar !== false) 
      $calendar = json_decode($calendar)->results;
      
   return $calendar;
}
<?PHP
$a = _alice_indico_get_events_json(2); //category = 2 CERN test indico events
print_r ($a);

If you have any questions, please do not hesitate to contact us

best regards
Guillermo