crazytonyi - Thank for the codes!!!!!!!!!!!! It really saved my time
coding all these.
but I just want to add some fixes on your codes... you need to add
the if(strlen(trim($appCalUri))==0) otherwise $appCalUri might go
empty after the search is done..
foreach($calFeed as $calendar){
if(strlen(trim($appCalUri))==0)
$appCalUri=(strcasecmp(trim($calendar->title->text),
"calendar name")==0)?$calendar->content->src:"";
}
--> same here too:
$noAppCal=false;
foreach ($calFeed as $calendar){
if($noAppCal==false)
$noAppCal = ($calendar -> title -> text == $new_title)?
false:true;
}
-------------------------------------------------------------------------------------------
I made some functions out of your codes...
so anyone who need this can cut and paste.
-------------------------------------------------------------------------------------------
//ADD NEW CALENDAR
function addNewCalendar($client, $new_title){
$gdataCal = new Zend_Gdata_Calendar($client);
$calFeed = $gdataCal->getCalendarListFeed();
$noAppCal=false;
foreach ($calFeed as $calendar){
if($noAppCal==false)
$noAppCal = ($calendar -> title -> text ==
$new_title)?false:true;
}
if($noAppCal){
$appCal = $gdataCal -> newListEntry();
$appCal -> title = $gdataCal-> newTitle($new_title);
$own_cal = "http://www.google.com/calendar/feeds/
default/owncalendars/full";
$gdataCal->insertEvent($appCal, $own_cal);
}
}
//CREATE AN EVENT ON DIFFERENT CALENDAR
function createEventDiffCalendar($client, $vals=array
("calendar_name"=>"my calendar2", "title"=>"Xmas Dinner",
"date"=>"12/25/2009", "start"=>"7:30 PM", "end"=>"9:30 PM")){
$gdataCal = new Zend_Gdata_Calendar($client);
$calFeed=$gdataCal->getCalendarListFeed();
foreach($calFeed as $calendar){
if(strlen(trim($appCalUri))==0)
$appCalUri=(strcasecmp(trim($calendar->title->text),
trim($vals['calendar_name']))==0)?$calendar->content->src:"";
}
$eventStart = date('Y-m-d\TH:i:sP', strtotime($start." ".$date));
$eventEnd = date('Y-m-d\TH:i:sP', strtotime($end." ".$date));
$newEvent = $gdataCal->newEventEntry();
$newEvent->title = $gdataCal->newTitle($title);
$when = $gdataCal->newWhen();
$when->startTime = $eventStart;
$when->endTime = $eventEnd;
$newEvent->when = array($when);
$createdEntry = $gdataCal->insertEvent($newEvent, $appCalUri);
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.