PHP 中的 CardDAV 服务器

发布于 2024-10-07 06:37:07 字数 210 浏览 6 评论 0原文

我目前正在寻找一种用 PHP 构建 CardDAV 服务器的方法。这是一个小型开发,希望能让我的公司共享来自/到多种设备的联系人,并由自定义后端/CRM 提供服务。

我开始尝试理解该协议,但最终却陷入了两倍的困惑。然后我阅读了 IETF 草案,但发现我什至不了解 WebDAV 本身的基础知识。

您建议我通过哪些方式开始学习 CardDAV、WebDAV 以及所有相关内容?

I am currently digging around for a way to build a CardDAV server in PHP. This is for a small development that would hopefully allow my company to share contacts from/to many kinds of devices, served by a custom backend/CRM.

I've started playing around, trying to understand the protocol but ended up twice as confused. I then read the IETF drafts but found out I don't even understand the basics of WebDAV itself.

In which ways would you recommend that I start learning about CardDAV, WebDAV and everything related?

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

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

发布评论

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

评论(2

情徒 2024-10-14 06:37:07

我很想知道我是否可以帮助解决有关 webdav 的一些困惑。大多数 IETF 标准使用的语言看起来非常迟钝。

WebDAV 背后的基本原理

HTTP 是为获取 Web 资源或者我应该说阅读而设计的。它并不是为了创作网络资源。

简而言之,WebDAV 提供了一整套远程文档访问功能,包括文件存储、目录管理和协作创作支持。

思考文件系统

理解 webdav 的最短途径是它与处理文件系统一样处理 Web 资源。

就像文件夹一样,集合作为特殊的 Web 资源,可以包含其他 Web 资源。它需要将其区分为特殊资源,因为功能(适用的方法与普通资源不同)

因此新方法诞生了 - mkcol

就像文件具有属性一样, Web 资源具有元属性,它提供有关 Web 资源的一些详细信息。 Web 资源内容本身可以像以前一样呈现(HTTP 已经为您做到了)。

简而言之,您还需要有查询元属性的方法 - PROPFIND 并更改它们 - PROPATCH。 XML 有效负载旨在查询和检索这些属性。

WebDAV 的方法是将属性存储在文件主体之外,可以在不获取整个主体的情况下进行查询,并且可以在不更改主体的情况下进行更新。

某些属性是 webdav 特定的。它们是出于需要而创建的。例如:资源类型属性。创建它是为了询问您是否正在访问特殊集合资源或集合中包含的普通网络资源。

请记住,GET(如 HTTP)获取资源,PUT 修改资源,DELETE 删除资源。

HTTP 的限制

要了解 webdav,您必须了解 HTTP 的限制。

  1. 它是无状态的,迫使用户从头开始构建搜索。
  2. 您不能说对特定集合中的所有资源也执行此操作。
  3. 它是只读的,不提供创作所需的协作功能。
  4. 它缺乏对多资源操作的支持。为了支持这一点,创建了深度标头,以便您可以判断它是否需要适用于所有资源。

WebDAV资源模型

  +--------+    +--------------+
  |Resource|... |Property      |
  +--------+    +--------------+
                +------++------+
                |Webdav||custom|
                +------++------+

  +-----------+
  |Dav root: /|......
  +-----------+     |     +--------+
                    |.....|Resource|
                    |     +--------+
                    |     +----------+
                    |.....|Collection|.....   +----------+
                    '     +----------+    |...|Collection|
                                          |   +----------+
                                          |    +--------+
                                          |....|Resource|
                                               +--------+

I am curious to see, if I can help resolve some confusion around webdav. Most IETF standards uses language that seems very obtuse.

Rationale behind WebDAV

HTTP was designed for fetching web resources or shall I say reading. It wasn't meant for authoring a web resource.

In short, WebDAV provides a full suite of remote document access capabilities, including file storage, directory management, and support for collaborative authoring.

Think of file system

The shortest route to understanding webdav is it's similarity of treating web resources like file system.

Just like folders, there are collections as special web resource that can contain other web resources. It needed to distinguish this as a special resource because capabilities (methods that would apply are different for a normal resource)

So new method was born - mkcol

Just like files have attributes, web resources have meta-properties which provides some details about the web resource. The web resource content itself can be rendered as before (HTTP already does that for you).

In short, you also need to have methods to enquire into meta-properties - PROPFIND and also change them - PROPATCH. The XML payloads were meant to enquire and retrieve these properties.

WebDAV's approach is to store properties outside the file body, can be queried without getting the entire body and updated without changing the body.

Some properties are webdav specific. They were created out of need. For ex: Resourcetype Property. It was created to enquire if you are taking to special collection resource or a normal web resource contained in a collection.

Remember that GET (Like HTTP) fetches a resource, PUT modifies a resource, and DELETE removes a resource.

Limitations of HTTP

To understand webdav, you have to understand the limitations of HTTP.

  1. It is stateless, forcing user to construct a search from scratch.
  2. You can't say do this too all resources in a particular collection.
  3. It is read only and does not provide collaboration capabilities required for authoring.
  4. It lacks support for multi-resource operations. To support that , depth header was created so that you could tell if it need to work on all resources.

WebDAV resource model

  +--------+    +--------------+
  |Resource|... |Property      |
  +--------+    +--------------+
                +------++------+
                |Webdav||custom|
                +------++------+

  +-----------+
  |Dav root: /|......
  +-----------+     |     +--------+
                    |.....|Resource|
                    |     +--------+
                    |     +----------+
                    |.....|Collection|.....   +----------+
                    '     +----------+    |...|Collection|
                                          |   +----------+
                                          |    +--------+
                                          |....|Resource|
                                               +--------+
泛滥成性 2024-10-14 06:37:07

您还可以尝试 DAViCal,这是一个用 PHP 编写、带有 Postgres 后端的 CalDAV 和 CardDAV 服务器。我发现它非常可靠,但要注意:开发至少暂时停止了。邮件列表上有一个补丁可以使 DAViCAL 与最新的 Apple 产品兼容(其中有很多需要解决的错误)。

该代码是开源的(不确定确切适用哪个许可证),但如果您仍然想自己构建一些东西,您可以看看 DAViCal 如何处理 Cal- 和 CardDAV。

http://www.davical.org

You could also try out DAViCal, a CalDAV and CardDAV server written in PHP with a Postgres backend. I find it to be very reliable, but beware: development has stopped at least temporarily. On the mailing list there is a patch available to make DAViCAl compatible with the latest Apple products (which come with a lot of bugs that need to be worked around).

The code is open sourced (not sure which licence applies exactly), but if you still want to build something yourself, you can take a look at how DAViCal handles Cal- and CardDAV.

http://www.davical.org

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