Welcome Guest, Not a member yet? Register   Sign In
problems with Zend Gdata objects in my model
#1

[eluser]alpineedge3[/eluser]
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:
Code:
Fatal error: Call 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!

Code:
<?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 = '[email protected]';
        $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
#2

[eluser]Unknown[/eluser]
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:
Code:
$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/dev...tingSingle

Cheers,
-Ryan
#3

[eluser]alpineedge3[/eluser]
ah yes that was the problem. thank you!




Theme © iAndrew 2016 - Forum software by © MyBB