Author |
|
MWaldorf Newbie
Joined: 31 March 2017
Online Status: Offline Posts: 9
|
Posted: 05 April 2017 at 5:14pm | IP Logged
|
|
|
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 |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 06 April 2017 at 2:56am | IP Logged
|
|
|
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 |
|
|
MWaldorf Newbie
Joined: 31 March 2017
Online Status: Offline Posts: 9
|
Posted: 06 April 2017 at 10:18am | IP Logged
|
|
|
duh, thanks, that did the trick!
|
Back to Top |
|
|