• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Facebook events to CMS made simple
PostPosted: Fri Mar 18, 2016 7:32 pm 
Offline
Forum Members
Forum Members

Joined: Fri Aug 03, 2007 3:11 pm
Posts: 10
Hello all,

After a long search in all the module i didn't find a scprit what a Facebook event place into a list at the CMS made simple site.

So i make it my self. Below stay the code:
past it into a user define tag.

-----------------------------------------------------------------------------
Code:

// paste the Facebook webcal link below and replace webcal to https
$webcal =("https://www.facebook.com/ical/u.php?uid=100002220601702&key=AQDlz7vxlN-7RIBv");

function build_table($aRevEvenementen){
//start table
    $html .= '<table width="80%">';
   $html .= '<tbody>';
// header row
    $html .= '<tr>';
    foreach($aRevEvenementen[0] as $key=>$value){
            $html .= '<td>' . $key . '</td>';
        }
    $html .= '</tr>';
// data rows
    foreach($aRevEvenementen as $value){
        $html .= '<tr>';
        foreach($value as $value2){
            $html .= '<td>' . $value2 . ' </td>';
        }
        $html .= '</tr>';
    }
// finish table and return it
   $html .= '</tbody>';
    $html .= '</table>';
    return $html;
    }

//Start main function

$aEvenementen = array ();
$handle = @fopen($webcal, "r");
if ($handle) {
    while (($buffer = fgets($handle, 4096)) !== false) {
        if (strpos($buffer, 'DTSTART') !== false){
          $DTstart_year = substr($buffer, 8, -14);  // DTSTART:20170114T180000Z
         $DTstart_month = substr($buffer, 12, -12);
         $DTstart_day = substr($buffer, 14, -10);
         $DTstart_hour = (substr($buffer, 17, -7) + 1); // add 1 hour time zone compensation
         $DTstart_min = substr($buffer, 19, -5);
         $Date = $DTstart_day.' - '.$DTstart_month.' - '.$DTstart_year; // return 14 - 01 - 2017
         $StartTime = $DTstart_hour.':'.$DTstart_min; // return opening 18:00
      }
      if (strpos($buffer, 'DTEND') !== false){
         $DTend_year = substr($buffer, 6, -14);
         $DTend_month = substr($buffer, 10, -12);
         $DTend_day = substr($buffer, 12, -10);
         $DTend_hour = (substr($buffer, 15, -7) + 1); // add 1 hour time zone compensation
         $DTend_min = substr($buffer, 17, -5);
         if (($DTend_hour - $DTstart_hour) == 3){ // needed when no end time is filled defaut 3h
            $EndTime = '-';
         }
         else{
         $EndTime = ' '.$DTend_hour.':'.$DTend_min;
         }
      }
      if (strpos($buffer, 'SUMMARY') !== false){
         $summary = substr($buffer, 8, -1);  // returns "Text - SUMMARY"
// put strings into a multiple array
         $aEvenementen[$i] ['Date'] = $Date;
         $aEvenementen[$i] ['Summary'] = $summary;
         $aEvenementen[$i] ['Start Time'] = $StartTime;
         $aEvenementen[$i] ['End Time'] = $EndTime;
         $i=$i+1;
      }
    }
    if (!feof($handle)) {
        echo "Error: unexpected fgets() fail\n";
   }
   fclose($handle);
}   

   $aRevEvenementen = array_reverse($aEvenementen); // place oldest date above
   echo build_table($aRevEvenementen);



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: blast2007


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
HostPapa CMS Made Simple hosting