EllisLab text mark
Advanced Search
     
problems with Zend Gdata objects in my model
Posted: 05 August 2008 10:54 PM
Joined: 2007-12-26
15 posts

Hi, I’m trying to add events to a google calendar and am running the code in model methods. I keep getting fatal errors like this:

Fatal errorCall to a member function newEventEntry() on a non-object in C:\wamp\www\delay-ad\system\application\models\scheduler_model.php 

I assume I just have object syntax incorrect. please help!

<?php
class Scheduler_model extends Model{
    
function Scheduler_model(){
        parent
::Model();

        require_once 
'c:\wamp\www\delay-ad\Zend\Loader.php';
        
Zend_Loader::loadClass('Zend_Gdata');
        
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
        
Zend_Loader::loadClass('Zend_Gdata_Calendar');
        
$user 'em@ail.com';
        
$pass 'p@ssw0rD';
        
$service Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
        
$client Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);
        
    
}
     
function addSubjectVisits($subID,$initials,$trial,$baselineDate){

        
foreach($visitTemplate as $v){
            $targetStamp 
$blStamp $v['relativeToBL'];
            
$windowSeconds $v['windowdays']*24*60*60
            
$earlyStamp $targetStamp $windowSeconds;
            
$lateStamp $targetStamp $windowSeconds;
            
        
$this->createGoogleCalendarVisit($trial,$v['visitName'],$targetStamp$earlyStamp,$lateStamp);

        
}
    }
    
    
function createGoogleCalendarVisit($trial$visitName$targetStamp$earlyStamp$lateStamp){
        $event 
$this->service->newEventEntry();
        
$event->content$this->service->newContent($title "on August 12, 2008");
        
$event->quickAdd $this->service->newQuickAdd("true");
        
$this->service->insertEvent($event);     
    
}

I got the Gdata code from here: Zend Manual

 
Posted: 07 August 2008 02:10 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2008-08-07
1 posts

Hi,

It looks like you’re not creating the $this->service object.  After you create the $client in the constructor, you probably want something like this:

$this->service = new Zend_Gdata_Calendar($client); 

In addition to the Zend docs, you can see here for snippets of code:
http://code.google.com/apis/calendar/developers_guide_php.html#CreatingSingle

Cheers,
-Ryan

 
Posted: 07 August 2008 06:26 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-12-26
15 posts

ah yes that was the problem. thank you!