搜索thru serverfault.com,stackoverflow.com,apple.stackexchange.com,谷歌搜索,仍然沒有得到太多。需要有人來幫忙。使用PHP從iCloud獲取電子名片
我試圖從iCloud帳戶獲取所有vCard。
我從Roundcube/CardDav的插件開始。
從物品,如:
stackoverflow.com/questions/24202551/manipulate-groups-in-icloud-with-carddav-protocol sabre.io/dav/building-a-carddav-客戶端/ sabre.io/dav/clients/osx-addressbook/ stackoverflow.com/questions/15111887/how-to-import-icloud-contacts-in-php# tools.ietf.org/html/rfc6352#section -8.7.1
我設法得到校長,校長的地址。但得到的0
這裏卡回送的ContentLength的最後一步是我做的:
- use icloud email as username
- use icloud password
要獲得校長,使用「HTTPS://contacts.icloud.com/」作爲URL ,PROPFIND,深度0:
<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:">
<d:prop>
<d:current-user-principal/>
</d:prop>
</d:propfind>
響應:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<multistatus xmlns="DAV:">
<response>
<href>/</href>
<propstat>
<prop>
<current-user-principal>
<href>/1331115018/principal/</href>
</current-user-principal>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
接下來,這裏是我做的就是回家,USI NG 「的https:/ /contacts.icloud.com/1331115018/principal/」,PROPFIND,深度0:
<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
<d:prop>
<card:addressbook-home-set/>
</d:prop>
</d:propfind>
響應:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<multistatus xmlns="DAV:">
<response>
<href>/1331115018/principal/</href>
<propstat>
<prop>
<addressbook-home-set xmlns="urn:ietf:params:xml:ns:carddav">
<href xmlns="DAV:">https://p44-contacts.icloud.com:443/1331115018/carddavhome/</href>
</addressbook-home-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
最後,這是我做的,試圖讓所有的電子名片,使用的是https://p44-contacts.icloud.com:443/1331115018/carddavhome/,REPORT,深度爲1:
<?xml version="1.0" encoding="utf-8" ?>
<C:addressbook-multiget xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:prop>
<D:getetag/>
<C:address-data>
<C:prop name="UID"/>
<C:prop name="EMAIL"/>
<C:prop name="FN"/>
</C:address-data>
</D:prop>
</C:addressbook-multiget>
響應:
<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:" xmlns:CD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/">
</multistatus>
或
<?xml version="1.0" encoding="utf-8" ?>
<C:addressbook-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:prop>
<D:getetag/>
<C:address-data>
<C:prop name="UID"/>
<C:prop name="EMAIL"/>
<C:prop name="FN"/>
</C:address-data>
</D:prop>
</C:addressbook-query>
響應:
<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:" xmlns:CD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/">
<response>
<href>/1331115018/carddavhome/</href>
<propstat>
<prop> <getetag>"[email protected]=9123588c-8038-439c-a547-19c866d1ed06"</getetag>
<address-data xmlns="urn:ietf:params:xml:ns:carddav">
</address-data>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
或
<?xml version="1.0" encoding="utf-8" ?>
<C:addressbook-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:prop>
<D:getetag/>
<C:address-data>
<C:prop name="UID"/>
<C:prop name="EMAIL"/>
<C:prop name="FN"/>
</C:address-data>
</D:prop>
<C:prop-filter name="EMAIL">
<C:text-match collation="i;unicode-casemap" match-type="equals">me</C:text-match>
</C:prop-filter>
</C:filter>
</C:addressbook-query>
響應:
"Didn't understand the report"
什麼d o我必須做什麼?
Thx答覆。但我仍然不知道應該使用哪種XML。你能分享更多嗎? – charleslcso