I am trying to obtain information based on the google contacts "events" (ie: anniversary's etct) "they seem to reference them as 'events'".
So none-the-less. I have been able to obtain some of the data in a shortened cleaned up format. This is the XML that I am working with to obtain this inf开发者_Go百科ormation.
[13] => Zend_Gdat
a_App_Extension_Element Object
(
[_rootElement:protected] => event
[_extensionElements:protected] => Array
(
[0] => Zend_Gdata_App_Extension_Element Object (
[_rootElement:protected] => when
[_extensionAttributes:protected] => Array (
[startTime] => Array (
[namespaceUri] =>
[name] => startTime
[value] => 2009-05-09))
[_text:protected] =>
)
)
[_extensionAttributes:protected] => Array (
[rel] => Array (
[namespaceUri] =>
[name] => rel
[value] => anniversary ))
[_text:protected] =>
)
So what I have done to obtain the TYPE of EVENT I use this code so far.
// Get All Events
foreach ($xml->event as $e) {
if($e['rel'] == "anniversary") {
// echo "This is true, this is anniversary";
}
}
And to Obtain the actual Event VALUE (the start Time). I THOUGHT I would use something like this running inside the for each loop.
foreach ($xml->event as $e) {
echo $e->when['startTime'];
}
But this just echo's NULL. I have tried many variations and can't seem to get it, although I'm not sure if it's just due to my over-tiredness. Any help would be greatly appreciated!
I was able to find a solution.
// Get All Events
foreach ($xml->event as $e) {
$defaults = $e->children('http://schemas.google.com/g/2005');
if($e['rel'] == "anniversary") {
$obj->anniversary = (string) $defaults->when->attributes()->startTime;
}
}
精彩评论