【问题标题】:Fetching select attributes from Google Contact API从 Google Contact API 获取选择属性
【发布时间】:2019-10-27 23:20:38
【问题描述】:

在使用https://developers.google.com/google-apps/contacts/v3/reference 时,我还没有想出一种方法,只让 Google 返回 gd$email 和 gd$name 而不是默认返回的以下内容。

[“id”, “gd$etag”, “updated”, “app$edited”, “category”, “title”, “link”, “gd$email”, “gd$name”]

对于我们的业务用例,我们只需要这两个属性,在响应中包含以上所有属性会增加响应负载,从而增加响应时间。

有什么线索吗?

【问题讨论】:

    标签: google-contacts-api


    【解决方案1】:

    您可以更改使用联系人 API 获得的响应。我尝试检索所有联系人,但在回复中仅包含电子邮件和电话号码。

    这里是https://www.google.com/m8/feeds/contacts/guntupalliswathi@gmail.com/full ?fields=entry/gd:email,entry/gd:phoneNumber 请求(我在 oauth 操场上试过)

    回复:

    <entry>
     <gd:email rel="http://schemas.google.com/g/2005#other" address="xxxx@domain.com" primary="true"/>
    </entry>
    <entry>
      <gd:phoneNumber rel="http://schemas.google.com/g/2005#mobile"   uri="tel:+91-0000-000-000"> </gd:phoneNumber>
     </entry>
     <entry>
     <gd:email rel="http://schemas.google.com/g/2005#other"  address="yyyy@domain.com" primary="true"/>
     </entry>
     <entry>
       <gd:phoneNumber rel="http://schemas.google.com/g/2005#mobile">(000) 000-0001</gd:phoneNumber>
     </entry> 
    

    如果您的问题没有解决,请告诉我。

    【讨论】:

    • 感谢您的回答。它使用 XML 作为输出格式,但奇怪的是它不使用 JSON 作为输出格式(谷歌给出 400 Bad Request)。这里有线索吗?
    【解决方案2】:

    对于 JSON 响应,您可以提供如下字段列表:

    https://www.google.com/m8/feeds/contacts/default/full/?alt=json&fields=feed(entry(gd$name(gd$fullName))),feed(entry(gd$email(address)))

    这将为您提供每位联系人的全名和电子邮件。希望这行得通。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      • 2012-07-02
      • 2012-11-07
      • 1970-01-01
      • 2012-06-29
      相关资源
      最近更新 更多