【问题标题】:Unable to track changers with sync-collection operation of Google CardDAV API无法使用 Google CardDAV API 的同步收集操作跟踪更改者
【发布时间】:2020-02-28 00:43:19
【问题描述】:

我正在尝试使用 Google CardDAV API 的同步收集操作。 documentation 中没有很好地解释。但我认为以下是他们在本文档中解释的内容。

首先,使用 propfind 操作从通讯录中发现同步令牌。以下是我的请求,我成功获得了同步令牌。

请求

Depth: 0
Content-Type: application/xml; charset=utf-8
<d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/">
  <d:prop>
     <d:displayname />
     <cs:getctag />
     <d:sync-token />
  </d:prop>
</d:propfind>

回应

ncoding="UTF-8"?>
<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:ical="http://apple.com/ns/ical/">
    <d:response>
        <d:href>/carddav/v1/principals/some@email.com/lists/default/</d:href>
        <d:propstat>
            <d:status>HTTP/1.1 200 OK</d:status>
            <d:prop>
                <d:displayname>Address Book</d:displayname>
                <d:sync-token>https://www.googleapis.com/carddav/v1/synctoken/SOMEIDINHERE</d:sync-token>
                <cs:getctag>"23fq3fqefas.8"</cs:getctag>
            </d:prop>
        </d:propstat>
    </d:response>
</d:multistatus>

然后我们必须使用 sync-token 进行同步收集操作以获取先前状态的更改,但这不会返回任何项目,无论我在https://contacts.google.com/ 的联系人列表中进行什么更改。

请求

<?xml version="1.0" encoding="utf-8" ?>
<d:sync-collection xmlns:d="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
  <d:sync-token>https://www.googleapis.com/carddav/v1/synctoken/SOMEIDINHERE</d:sync-token>
  <d:sync-level>1</d:sync-level>
  <d:prop>
     <d:displayname />
     <d:current-user-principal />
     <d:principal-URL/>
  </d:prop>
</d:sync-collection>

回应

<?xml version="1.0" encoding="UTF-8"?>
<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:ical="http://apple.com/ns/ical/">
    <d:sync-token>https://www.googleapis.com/carddav/v1/synctoken/SOMEIDINHERE </d:sync-token>

</d:multistatus>

请让我知道我做错了什么。

【问题讨论】:

    标签: google-api webdav google-contacts-api carddav


    【解决方案1】:

    一般来说,正常的操作模式是使用空同步令牌(参见https://www.rfc-editor.org/rfc/rfc6578#section-3.8)发出第一个同步集合,并在后续请求中使用响应中返回的同步令牌。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 2012-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多