我正在尝试使用PHP客户端连接到Caldav服务器。我找到了这个客户端库http://repo.or.cz/w/davical.git/blob/HEAD:/inc/caldav-client.php,我试图按照这里交换的域/用户名/密码示例。
$cal = new CalDAVClient( "http://192.168.10.11/caldav/users/domain.com/user-name/", "user-name", "password" );
$options = $cal->DoOptionsRequest();
if ( isset($options["PROPFIND"]) ) {
// Fetch some information about the events in that calendar
$cal->SetDepth(1);
$folder_xml = $cal->DoXMLRequest("PROPFIND", '<?xml version="1.0" encoding="utf-8" ?><propfind xmlns="DAV:"><prop><getcontentlength/><getcontenttype/><resourcetype/><getetag/></prop></propfind>' );
}
var_dump($folder_xml);exit;
那已经给了我一些403 Forbidden back:
string(1928) "HTTP/1.1 207 Multi status
Connection: Close
Content-Type: text/xml; charset="utf-8"
Date: Fri, 2 Oct 2015 07:02:28 GMT
DAV: 1, access-control, calendar-access, calendar-schedule, calendar-proxy, calendar-availability, calendarserver-private-events, calendar-auto-schedule, calendarserver-principal-property-search, calendarserver-sharing, calendarserver-sharing-no-scheduling, addressbook, calendar-default-alarms
Server: Kerio Connect 8.5.1
Transfer-Encoding: chunked
X-UA-Compatible: IE=edge
584
<?xml version="1.0" encoding="UTF-8"?><a:multistatus xmlns:a="DAV:" xmlns:c="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:b="xml:"><a:response><a:href>/caldav/users/domain.com/user-name/</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:resourcetype><a:collection/><a:principal/></a:resourcetype></a:prop></a:propstat><a:propstat><a:status>HTTP/1.1 403 Forbidden</a:status><a:prop><a:getcontentlength/><a:getcontenttype/><a:getetag/></a:prop></a:propstat></a:response><a:response xmlns:d="http://calendarserver.org/ns/"><a:href>/caldav/users/domain.com/user-name/calendar-proxy-write/</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:resourcetype><a:collection/><a:principal/><d:calendar-proxy-write/></a:resourcetype></a:prop></a:propstat><a:propstat><a:status>HTTP/1.1 403 Forbidden</a:status><a:prop><a:getcontentlength/><a:getcontenttype/><a:getetag/></a:prop></a:propstat></a:response><a:response xmlns:e="http://calendarserver.org/ns/"><a:href>/caldav/users/domain.com/user-name/calendar-proxy-read/</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:resourcetype><a:collection/><a:principal/><e:calendar-proxy-read/></a:resourcetype></a:prop></a:propstat><a:propstat><a:status>HTTP/1.1 403 Forbidden</a:status><a:prop><a:getcontentlength/><a:getcontenttype/><a:getetag/></a:prop></a:propstat></a:response></a:multistatus>
0
"
我知道在哪里可以修复禁止的错误?我不知道为什么我没有得到任何东西。
修改 我终于找到了一些时间来深入研究这个,但只找到了一些日志,还没有解决方案。无法弄清楚到底出了什么问题,但这就是我在日志中找到的内容
[07/Dec/2015 15:29:51][21240] {https} Task 202600 handler BEGIN
[07/Dec/2015 15:29:51][21240] {https} Task 202600 handler starting
[07/Dec/2015 15:29:51][21240] {https} HTTPS connection from 192.168.10.91:59937 started
[07/Dec/2015 15:29:51][21240] {https} PROPFIND request for URI /caldav/users/mydomain.com/myuser/
[07/Dec/2015 15:29:51][21240] {https} User-Agent header: DAViCalClient
[07/Dec/2015 15:29:51][21240] {webdav} PROPFIND /caldav/users/mydomain.com/myuser/ received from remote host='192.168.10.91', user-agent='DAViCalClient'
[07/Dec/2015 15:29:51][21240] {webdav} PropertyRequestReader: found property "getcontentlength" from namespace "DAV:"
[07/Dec/2015 15:29:51][21240] {webdav} PropertyRequestReader: found property "getcontenttype" from namespace "DAV:"
[07/Dec/2015 15:29:51][21240] {webdav} PropertyRequestReader: found property "resourcetype" from namespace "DAV:"
[07/Dec/2015 15:29:51][21240] {webdav} PropertyRequestReader: found property "getetag" from namespace "DAV:"
[07/Dec/2015 15:29:51][21240] {webdav} (B)PROPFIND: User myuser@mydomain.com is listing properties of principal: myuser<_at_>mydomain.com
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontentlength" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontenttype" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getetag" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} (B)PROPFIND: User myuser@mydomain.com is listing properties of principal: myuser<_at_>mydomain.com
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontentlength" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontenttype" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getetag" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} (B)PROPFIND: User myuser@mydomain.com is listing properties of principal: myuser<_at_>mydomain.com
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontentlength" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontenttype" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getetag" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {https} Response: HTTP/1.1 207 Multi status
[07/Dec/2015 15:29:51][21240] {https} Request finished in 0.00 s, received 373 bytes, sent 1916 bytes
[07/Dec/2015 15:29:51][21240] {https} Task 202600 handler END
答案 0 :(得分:1)
问题是您将请求发送到用户主路径,而不是日历集合,也不会发送到日历主页。
不需要为不支持@IBAction func replaceCurrencies(sender: AnyObject) {
UIView.animateWithDuration(0.5, animations: {
self.arrows.transform = CGAffineTransformRotate(self.arrows.transform, CGFloat(M_PI))
})
}
请求的资源定义属性DAV:getcontentlength
,DAV:getcontenttype
和DAV:getetag
。正如您在回复中看到的,属性DAV:resourcetype
实际上有一个值,表示它是<?php echo date("d.m.Y", get_post_meta($post->ID, 'courses_date', true)); ?>
和GET
。
我认为Kerio的开发人员决定为这些属性返回403而不是404,因为这些属性不仅缺少,因为它们尚未设置,但因为它们不适用于资源。
要查找用户的日历,您需要先找到日历主页。用户的日历位于他的日历主页下方。
要查找calendar-home,只需在同一路径上为属性CALDAV:calendar-home-set
执行DAV:collection
即可。这将返回用户拥有的所有日历家庭(通常只有一个)。