Google Contacts API - 选择事件数据

发布于 2024-12-03 10:59:02 字数 1677 浏览 0 评论 0原文

我试图根据谷歌联系人“事件”(即:周年纪念日等)获取信息“他们似乎将它们称为“事件””。

尽管如此。我已经能够以缩短的清理格式获得一些数据。 这是我用来获取此信息的 XML。

[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] => 
        )

那么到目前为止,我为获取事件类型所做的工作是使用此代码。

//    Get All Events
foreach ($xml->event as $e) {                       
    if($e['rel'] == "anniversary") {
        // echo "This is true, this is anniversary";
    }
}

并获取实际的Event VALUE(开始时间)。我想我会在 foreach 循环中使用类似的东西。

foreach ($xml->event as $e) {                       
    echo $e->when['startTime'];
}

但这只是回显 NULL。 我尝试了很多变化,但似乎无法实现,尽管我不确定这是否只是因为我过度疲劳。任何帮助将不胜感激!

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 information.

[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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扭转时空 2024-12-10 10:59:02

我找到了解决方案。

//    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;
    }
}

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;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文