Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Pro

 AfterLogic Forum : AfterLogic WebMail Pro
Subject Topic: add Calendar event Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
MWaldorf
Newbie
Newbie


Joined: 31 March 2017
Online Status: Offline
Posts: 9
Posted: 05 April 2017 at 5:14pm | IP Logged Quote MWaldorf

I'm using Webmail Pro PHP/Windows 10/Php 5.3.28 and I'm trying to add a calendar event programically. I'm able to add events through the webmail interface.

Here's my code. It doesn't error out, but it doesn't add events. Any ideas what I'm doing wrong? Thanks, Mel

       $oApiIntegratorManager = CApi::Manager('integrator');
        $oAccount = $oApiIntegratorManager->LoginToAccount($sEmail, $sPassword);
        if ($oAccount)
        {
                              $oApiCalManager = CApi::Manager("calendar");
                              $oCals = $oApiCalManager->getCalendars($oAccount);
                              $oCalIds = array();
            if ($oCals) {
               foreach ($oCals as $oCal) {
                         $oCalIds[]=$oCal["Id"];
               }
            }
            $sCalendarId = $oCalIds[0];

                              if ($sCalendarId!="") {
                                 &n bsp;$oEvent = new CEvent();
                                 &n bsp;$oEvent->IdCalendar = $sCalendarId;
                                 &n bsp;$MYTZ = new DateTimeZone('Etc/GMT+8');
                                 &n bsp;$oEvent->Start = getIcalDate("2017-04-29 02:00:00");
                                 &n bsp;$oEvent->End = getIcalDate("2017-04-29 04:00:00");
                                 &n bsp;$oEvent->AllDay = 0;
                                 &n bsp;$oEvent->Name = "Name";
                                 &n bsp;$oEvent->Description = "Description";
                                 &n bsp;$oEvent->Location = "Location";
                                 &n bsp;$oEvent->Alarms = array(180,60);
                                 &n bsp;$oApiCalendarManager->createEvent($oAccount,$oEvent);
                              } else {
                                 &n bsp;echo 'Calendar not found';
                              }
        }
        else
        {
            // login error
            echo $oApiIntegratorManager->GetLastErrorMessage();
        }
Back to Top View MWaldorf's Profile Search for other posts by MWaldorf
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6038
Posted: 06 April 2017 at 2:56am | IP Logged Quote Igor

The problem in the code is this specific line:

Code:
$oApiCalendarManager->createEvent($oAccount,$oEvent);


When you're creating calendar manager object, it is called $oApiCalManager, not $oApiCalendarManager - and with a proper error_reporting setting in PHP configuration, you would get a Notice pointing to that.

Once that's corrected, the event is added to the calendar just fine.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
MWaldorf
Newbie
Newbie


Joined: 31 March 2017
Online Status: Offline
Posts: 9
Posted: 06 April 2017 at 10:18am | IP Logged Quote MWaldorf

duh, thanks, that did the trick!
Back to Top View MWaldorf's Profile Search for other posts by MWaldorf
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide