Here is the class i've write to post events to the calendar. (thanks
for any help you can offer)

// EXAMPLE OF TRYING TO POST AN EVENT

$gcalendar = new gcalendar;

// This works when posting to the default calendar
$gcalendar->create('','Testing','2008-08-30 10:00','2008-08-30
11:00','Some test content here');

// Most of the time this returns the error from my original post
$gcalendar->create('Accounts Payable','Testing','2008-08-30
10:00','2008-08-30 11:00','Some test content here');

// CLASS BELOW

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');

class gcalendar
{
        var $client;
        var $calendars = array
                                                (
                                                        'Staff Meetings' => 
'[EMAIL PROTECTED]',
                                                        'Accounts Payable' =>
'[EMAIL PROTECTED]',
                                                        'Accounts Receivable' =>
'[EMAIL PROTECTED]',
                                                        'Order Management' =>
'[EMAIL PROTECTED]',
                                                        'Outgoing Mail' =>
'[EMAIL PROTECTED]',
                                                        'Production' =>
'[EMAIL PROTECTED]',
                                                        'Quotes & Sales' =>
'[EMAIL PROTECTED]',
                                                        'Tasks & To Do\'s' =>
'[EMAIL PROTECTED]'
                                                )
                                                ;
        function gcalendar(){
                $this->client = $this-
>getClientLoginHttpClient('LOGINHERE','PASSWORDHERE');
        }

        function getClientLoginHttpClient($user, $pass)
        {
          $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;

          $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass,
$service);
          return $client;
        }

        function create($calendar,$title,$stime, $etime, $desc, $where=''){
                  $gc = new Zend_Gdata_Calendar($this->client);
                  $newEntry = $gc->newEventEntry();
                  $newEntry->title = $gc->newTitle(trim($title));
                  $newEntry->where  = array($gc->newWhere($where));

                  $newEntry->content = $gc->newContent($desc);
                  $newEntry->content->type = 'text';

                  $startDate = date("Y-m-d",strtotime($stime));
                  $startTime = date("H:i",strtotime($stime));

                  $endDate = date("Y-m-d",strtotime($etime));
                  $endTime = date("H:i",strtotime($etime));

                  $tzOffset = 0;

                  $when = $gc->newWhen();
                  $when->startTime = "{$startDate}T{$startTime}:00";
                  $when->endTime = "{$endDate}T{$endTime}:00";
                  $newEntry->when = array($when);
                  if(isset($this->calendars[$calendar])){
                        $calurl = 'http://www.google.com/calendar/feeds/'.$this-
>calendars[$calendar].'/private/full';
                        $createdEntry = $gc->insertEvent($newEntry,$calurl);
                  }else{
                        $createdEntry = $gc->insertEvent($newEntry);
                  }

                  return $createdEntry->id->text;
        }
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to