在某些帐户中,Google Feed / contacts /的调用不会返回groupMembershipInfo

时间:2013-11-18 17:27:26

标签: php google-apps-script google-api gdata google-contacts

在新创建的Google帐户中,当我拨打https://www.google.com/m8/feeds/contacts/default/full?v=3.0&alt=json时,在部分响应中,我会收到一个名为“gContact $ groupMembershipInfo”的数组,该数组会告诉我某个联系人所在的群组。

在我测试的一些较旧的Google帐户中,即使该帐户的联系人列表中存在与该组帐户中的实际组成员身份的联系人,此阵列也完全丢失。

获取信息的代码:

try {
    $req = new Google_HttpRequest(
        "https://www.google.com/m8/feeds/contacts/default/full?v=3.0&alt=json" . ($query == "" ? "" : "&q=$query")
    );
} catch (Exception $e) {
    print_message("ERROR", "Error contacting Google servers. Please try again.");
    return;
}
$val = $client->getIo()->authenticatedRequest($req);

$contacts_object = json_decode($val->getResponseBody())->feed->entry;
echo '<pre>' . print_r($contacts_object, true) . '</pre>';

这是输出信息。请注意每个联系人上的ID字符串:工作帐户使用哈希来标识联系人,而非工作帐户使用顺序整数索引来执行此操作。

我想要的输出,以及我自己的帐户:

Array
(
    [0] => stdClass Object
        (
            [gd$etag] => "QXs4..."
            [id] => stdClass Object
                (
                    [$t] => http://www.google.com/m8/feeds/contacts/redacted%40gmail.com/base/11...c1
                )

            [updated] => stdClass Object
                (
                    [$t] => 2013-10-21T15:43:10.536Z
                )

            [app$edited] => stdClass Object
                (
                    [xmlns$app] => http://www.w3.org/2007/app
                    [$t] => 2013-10-21T15:43:10.536Z
                )

            ...
            [category, title, link, gd$name, gd$email, gd$phoneNumber, gd$structuredPostalAddress]
            ...

            [gContact$groupMembershipInfo] => Array
                (
                    [0] => stdClass Object
                        (
                            [deleted] => false
                            [href] => http://www.google.com/m8/feeds/groups/redacted%40gmail.com/base/6
                        )

                    [1] => stdClass Object
                        (
                            [deleted] => false
                            [href] => http://www.google.com/m8/feeds/groups/redacted%40gmail.com/base/55f1...cdad
                        )

                    [2] => stdClass Object
                        (
                            [deleted] => false
                            [href] => http://www.google.com/m8/feeds/groups/redacted%40gmail.com/base/2d7a...8456
                        )

                )

        )
)

我对问题帐户的回复:

Array
(
    [0] => stdClass Object
        (
            [gd$etag] => "QH4_e...LRwQ."
            [id] => stdClass Object
                (
                    [$t] => http://www.google.com/m8/feeds/contacts/redacted%40gmail.com/base/2
                )

            [updated] => stdClass Object
                (
                    [$t] => 2012-07-16T01:10:01.041Z
                )

            [app$edited] => stdClass Object
                (
                    [xmlns$app] => http://www.w3.org/2007/app
                    [$t] => 2012-07-16T01:10:01.041Z
                )

            [category] => Array
                (
                    [0] => stdClass Object
                        (
                            [scheme] => http://schemas.google.com/g/2005#kind
                            [term] => http://schemas.google.com/contact/2008#contact
                        )

                )

            [title] => stdClass Object
                (
                    [$t] => Redacted
                )

            [link] => Array
                (
                    [0] => stdClass Object
                        (
                            [rel] => http://schemas.google.com/contacts/2008/rel#photo
                            [type] => image/*
                            [href] => https://www.google.com/m8/feeds/photos/media/redacted%40gmail.com/2?v=3.0
                            [gd$etag] => "cT52JngabCt7I2BqPWgHTk1ZNmcaPT8mTCY."
                        )

                    [1] => stdClass Object
                        (
                            [rel] => self
                            [type] => application/atom+xml
                            [href] => https://www.google.com/m8/feeds/contacts/redacted%40gmail.com/full/2?v=3.0
                        )

                    [2] => stdClass Object
                        (
                            [rel] => edit
                            [type] => application/atom+xml
                            [href] => https://www.google.com/m8/feeds/contacts/redacted%40gmail.com/full/2?v=3.0
                        )

                )

            [gd$name] => stdClass Object
                (
                    [gd$fullName] => stdClass Object
                        (
                            [$t] => Redacted
                        )

                    [gd$givenName] => stdClass Object
                        (
                            [$t] => Redacted
                        )

                )

            [gd$email] => Array
                (
                    [0] => stdClass Object
                        (
                            [rel] => http://schemas.google.com/g/2005#other
                            [address] => redacted@gmail.com
                            [primary] => true
                        )

                )

        )
)

如您所见,[gContact $ groupMembershipInfo]缺失。

问题帐户是否可能是遗留问题?有没有其他方法可以获取特定联系人的组信息?

0 个答案:

没有答案