View
9.748
Download
0
Category
Preview:
Citation preview
APIs de Google CalendarAPIs de Google CalendarGuía del programador v 1.0
Grupo # 5
Paul VillacresesAndrés Loor
AgendaAgenda
� Visión General
� ¿Qué es el API de Google Calendar?
� Diagrama de Google API
� Lenguajes de Programación
� PHP� PHP
� Librería ZendGdata
� Configuración y prueba
� Acceso al núcleo
� Taller Práctico
� Ejemplos de Calendario
� Preguntas
Visión GeneralVisión General
¿Que es el API de Google Calendar?¿Que es el API de Google Calendar?
� El Protocolo de datos de Google permite a los desarrolladores crear aplicaciones que accedan a todas las funciones de que accedan a todas las funciones de Google Calendar.
Diagrama de Google APIDiagrama de Google API
Puedes utilizar esta API para:Puedes utilizar esta API para:
� Añadir eventos futuros de forma programada a Google Calendar para anunciarlos
� Crear una aplicación para sincronizar Google Calendar y dispositivos móviles
� Crear Combinaciones con otras APIs como Google Maps o Youtube
Integración Calendario Google en Integración Calendario Google en su Pagina Websu Pagina Web
Ejemplo de Protocolo Google APIEjemplo de Protocolo Google API
Lenguajes de ProgramaciónLenguajes de Programación
� .NET
� Java
� JavaScript� JavaScript
� PHP
� Python
PHPPHP
� Zend Google Data Client Library
� http://framework.zend.com/download/gdata
� Setear include_path en php.ini
� Habilitar Windows Extensions
◦ extension=php_openssl.dll
Vista grafica de Librería ZendVista grafica de Librería Zend
Aspectos GeneralesAspectos Generales
� Estas interfaces utilizan 2 formatos de sindicación estándar basados en XML:
◦ Atom◦ Atom
� Es mas reciente y tiene mas funciones
◦ RSS
� Es mas antiguo y tiene varias versiones
ZendGdataZendGdata--1.9.2 Library1.9.2 Library
php.iniphp.ini
CheckerChecker
Acceso al núcleoAcceso al núcleo
� Este código solicita acceso al núcleo de la clase Zend_Gdata
� Dependiendo de la aplicación se elige el método de autenticación
require_once 'Zend/Loader.php'; 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');
Taller PrácticoTaller Práctico
� Autenticación
◦ AuthSub Proxy
◦ Magic cookie
◦ ClientLogin User/Password◦ ClientLogin User/Password
$user = 'andresloor@gmail.com';
$pass = ‘**********';
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);
Taller PrácticoTaller Práctico
� Consultar Lista de Calendario
$gdataCal = new Zend_Gdata_Calendar($client);
$calFeed = $gdataCal->getCalendarListFeed();$calFeed = $gdataCal->getCalendarListFeed();
echo '<h1>' . $calFeed->title->text . '</h1>‘;
foreach ($calFeed as $calendar) {
echo '<li>' . $calendar->title->text .
echo '<li>‘ . $calendar->id->text ;
}
Taller PrácticoTaller Práctico
�Consultar Eventos◦ Sin parámetros de consulta
$gdataCal = new Zend_Gdata_Calendar($client);
$eventFeed = $gdataCal->getCalendarEventFeed();$eventFeed = $gdataCal->getCalendarEventFeed();
foreach ($eventFeed as $event) {
echo "\t<li>" . $event->title->text . " (" . $event->id->text . ")\n";
foreach ($event->when as $when) {
echo "\t\t\t<li>Starts: " . $when->startTime . "</li>\n“;
}
}
Taller PrácticoTaller Práctico◦ Para un rango de fechas especifico
$gdataCal = new Zend_Gdata_Calendar($client);
$query = $gdataCal->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
$query->setProjection('full');
$query->setOrderby('starttime');$query->setOrderby('starttime');
$query->setStartMin($startDate);
$query->setStartMax($endDate);
$eventFeed = $gdataCal->getCalendarEventFeed($query);
foreach ($eventFeed as $event) {
echo "\t<li>" . $event->title->text . " (" . $event->id->text . ")\n";
foreach ($event->when as $when) {
echo "\t\t\t<li>Starts: " . $when->startTime . "</li>\n“;
}
}
Taller PrácticoTaller Práctico◦ Consulta Completa
$gdataCal = new Zend_Gdata_Calendar($client);
$query = $gdataCal->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
$query->setProjection('full');$query->setProjection('full');
$query->setQuery($fullTextQuery);
$eventFeed = $gdataCal->getCalendarEventFeed($query);
foreach ($eventFeed as $event) {
echo "\t<li>" . $event->title->text . " (" . $event->id->text . ")\n“;
foreach ($event->when as $when) {
echo "\t\t\t<li>Starts: " . $when->startTime . "</li>\n“;
}
}
Taller PrácticoTaller Práctico
� Crear Eventos◦ Simple
$gdataCal = new Zend_Gdata_Calendar($client);
$newEvent = $gdataCal->newEventEntry();
$newEvent->title = $gdataCal->newTitle($title);
$newEvent->where = array($gdataCal->newWhere($where));$newEvent->where = array($gdataCal->newWhere($where));
$newEvent->content = $gdataCal->newContent("$desc");
$when = $gdataCal->newWhen();
$when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
$when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";
$newEvent->when = array($when);
$createdEvent = $gdataCal->insertEvent($newEvent);
Taller PrácticoTaller Práctico
◦ Rápido$gdataCal = new Zend_Gdata_Calendar($client);
$event = $gdataCal->newEventEntry();
$event->content = $gdataCal->newContent($quickAddText);
$event->quickAdd = $gdataCal->newQuickAdd('true');
$newEvent = $gdataCal->insertEvent($event);$newEvent = $gdataCal->insertEvent($event);
◦ Contenido Web
◦ Recurrentes
Taller PrácticoTaller Práctico� Actualizar Eventos
$gdataCal = new Zend_Gdata_Calendar($client);
$eventOld =
$gdataCal->getCalendarEventEntry('http://www.google.com/calendar/feeds/default/private/full/' . $eventId);
echo "Old title: " . $eventOld->title->text . "<br />\n";
$eventOld->title = $gdataCal->newTitle($newTitle);
try {
$eventOld->save();
} catch (Zend_Gdata_App_Exception $e) {
var_dump($e);
return null;
}
$eventNew =
$gdataCal>getCalendarEventEntry('http://www.google.com/calendar/feeds/default/private/full/' . $eventId);
Taller PrácticoTaller Práctico
� Eliminar Eventos
$gdataCal = new Zend_Gdata_Calendar($client);
$event = $gdataCal->getCalendarEventEntry('http://www.google.com/ calendar/feeds/default/private/full/q98ske4cbpj0egqcmkuce1bdgc');calendar/feeds/default/private/full/q98ske4cbpj0egqcmkuce1bdgc');
$event->delete();
Ejemplos de CalendarioEjemplos de Calendario
� http://localhost/prueba/pruebacalendario.php
� http://gcal.appspot.com/calvis/demo2.html
PreguntasPreguntasPreguntasPreguntas
Recommended