Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

bkawakami

[Resolvido] Recebendo data do API Google Calendar

Recommended Posts

Olá Pessoal, como estão?

 

Estou fazendo uma API de integração do meu sistema com a agenda do Google. Tudo esta correndo bem, desde a autenticação multi usuário com o Magic Cookie da Google até receber de volta o conteúdo. Porém me deparei com um pequeno problema e acredito que vocês consigam me ajudar.

 

Me deparei com o seguinte erro problema. Estou tentando chamar as datas dos meu eventos no calendário com método getWhen(). Veja o que ele me retorna com o print_r():

 

Array ( [0] => Zend_Gdata_Extension_When Object ( [_rootElement:protected] => when [_reminders:protected] => Array ( [0] => Zend_Gdata_Extension_Reminder Object ( [_rootElement:protected] => reminder [_absoluteTime:protected] => [_method:protected] => alert [_days:protected] => [_hours:protected] => [_minutes:protected] => 10 [_rootNamespace:protected] => gd [_rootNamespaceURI:protected] => [_extensionElements:protected] => Array ( ) [_extensionAttributes:protected] => Array ( ) [_text:protected] => [_namespaces:protected] => Array ( [atom] => Array ( [1] => Array ( [0] => http://www.w3.org/2005/Atom ) ) [app] => Array ( [1] => Array ( [0] => http://purl.org/atom/app# ) [2] => Array ( [0] => http://www.w3.org/2007/app ) ) [gd] => Array ( [1] => Array ( [0] => http://schemas.google.com/g/2005 ) ) [openSearch] => Array ( [1] => Array ( [0] => http://a9.com/-/spec/opensearchrss/1.0/ ) [2] => Array ( [0] => http://a9.com/-/spec/opensearch/1.1/ ) ) [rss] => Array ( [1] => Array ( [0] => http://blogs.law.harvard.edu/tech/rss ) ) ) ) ) [_startTime:protected] => 2012-06-27T01:30:00.000-03:00 [_valueString:protected] => [_endTime:protected] => 2012-06-27T07:00:00.000-03:00 [_rootNamespace:protected] => gd [_rootNamespaceURI:protected] => [_extensionElements:protected] => Array ( ) [_extensionAttributes:protected] => Array ( ) [_text:protected] => [_namespaces:protected] => Array ( [atom] => Array ( [1] => Array ( [0] => http://www.w3.org/2005/Atom ) ) [app] => Array ( [1] => Array ( [0] => http://purl.org/atom/app# ) [2] => Array ( [0] => http://www.w3.org/2007/app ) ) [gd] => Array ( [1] => Array ( [0] => http://schemas.google.com/g/2005 ) ) [openSearch] => Array ( [1] => Array ( [0] => http://a9.com/-/spec/opensearchrss/1.0/ ) [2] => Array ( [0] => http://a9.com/-/spec/opensearch/1.1/ ) ) [rss] => Array ( [1] => Array ( [0] => http://blogs.law.harvard.edu/tech/rss ) ) ) ) )

 

Não consigo acessar as arrays startTime nem endTime, que são as arrays que eu precisava acessar... Vejam o código:

       try {
           $eventFeed = $service->getCalendarEventFeed($query);
       } catch (Zend_Gdata_App_Exception $e) {
           echo "Error: " . $e->getMessage();
       }

       // Iterate through the list of events, outputting them as an HTML list
       foreach ($eventFeed as $event) {
           $eventURL = "$event->id";

           try {
               $event = $service->getCalendarEventEntry($eventURL);

               echo $event->getTitle();
               print_r($event->getWhen());
           } catch (Zend_Gdata_App_Exception $e) {
               echo "Error: " . $e->getMessage();
           }

       }

 

Ficaria muito grato se alguém me ajudasse a acessar as arrays de endTime e startTime

 

Consegui galera! Bem inviável a metodologia para se fazer, bom pelo menos eu achei isso, vamos ver se o Zend na versão 2.0 melhora isso...

 

Segue o código:

       try {
           $eventFeed = $service->getCalendarEventFeed($query);
       } catch (Zend_Gdata_App_Exception $e) {
           echo "Error: " . $e->getMessage();
       }

       // Iterate through the list of events, outputting them as an HTML list
       foreach ($eventFeed as $event) {
           $eventURL = "$event->id";

           try {
               $event = $service->getCalendarEventEntry($eventURL);

               $When = $event->getWhen();
               $objWhen =  $When[0];
               echo $event->getTitle();
               print_r($objWhen->startTime);
           } catch (Zend_Gdata_App_Exception $e) {
               echo "Error: " . $e->getMessage();
           }

       }

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.