Apple iCloud访问UWP应用程序中的联系人 [英] Apple iCloud access to contacts in uwp application

查看:121
本文介绍了Apple iCloud访问UWP应用程序中的联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在UWP应用程序中访问我的iCloud联系人. 我知道我可以通过 Google的People API 访问我的Gmail联系人,而我的Outlook联系人可以通过Microsoft的图形api 胜过人们的api .

I am trying to access my iCloud contacts in my UWP application. I know that I can access my Gmail Contacts through Google's People API and my Outlook contacts through Microsoft's Graph api OR Outook people api .

Apple是否提供可用于获取,更新,添加,删除联系人的API(Rest或其他方式)?如果是,是否有一个教程逐步介绍了如何设置访问iCloud api?

Does Apple provide an API (Rest or otherwise) that could be leveraged to fetch, update, add, delete contacts? If yes, is there a tutorial that walks through how to setup access iCloud api?

推荐答案

因此,如果您只想获取联系人(并以JSON格式),则我以前的答案可能是解决方法. 但是,由于我希望能够对Apple帐户执行CRUD操作,因此更好的方法是使用icloud/apple支持的CARDDAV协议.

So, if you just want to fetch the contacts (and in JSON format) my previous answer is probably the way to go. However, as I wanted to be able to perform CRUD operations on Apple account, a better way is to use the CARDDAV protocol that icloud/apple supports.

  1. 使用基本身份验证获取主要用户(此基本身份验证中使用的密码必须作为应用密码生成 https://contacts.icloud.com 上触发PROPFIND请求带有请求内容:
  1. Get the principle user using basic authentication (the password used in this basic authentication would have to be generated as an app password here) by firing a PROPFIND request at https://contacts.icloud.com with the request content:

<propfind
xmlns="DAV:">
<prop>
    <current-user-principal/>
</prop>
</propfind> 

  1. 上一步将使您可以检索格式为/1437425399/principal/的原理.现在,您可以在链接 https://contacts上针对该用户触发PROPFIND查询. icloud.com/1437425399/principal 具有以下请求内容:
  1. The previous step will let you retrieve a principle which will be of the format /1437425399/principal/. Now, you can fire a PROPFIND query the home-set for this user at the link https://contacts.icloud.com/1437425399/principal with the following request content:

<propfind
    xmlns="DAV:"
    xmlns:c="urn:ietf:params:xml:ns:carddav">
    <prop>
        <c:addressbook-home-set/>
    </prop>
</propfind>

  1. 从上一个请求中,您将以 https://p48-contacts.icloud.com:443/1437425399/carddavhome/.您可以在首页链接上使用以下PROPFIND请求查询用户的电子名片的位置:
  1. From the previous request, you will get the link to the homeset in the format https://p48-contacts.icloud.com:443/1437425399/carddavhome/. You can query where the vcards for the user exist using the following PROPFIND request at the home-set link:

<propfind
xmlns="DAV:">
<prop>
    <resourcetype/>
</prop>
</propfind>

  1. 您将收到放置所有卡的位置(例如/1437425399/carddavhome/card/).使用地址簿查询,现在您可以在上一个链接中收到的端点上发起REPORT请求:

<c:addressbook-query
    xmlns="DAV:"
    xmlns:c="urn:ietf:params:xml:ns:carddav">
    <prop>
    </prop>
</c:addressbook-query>

  1. 这将为您提供标签中的所有卡片.然后,您可以使用地址簿多报告请求来获取多张卡片:

<c:addressbook-multiget
    xmlns="DAV:"
    xmlns:c="urn:ietf:params:xml:ns:carddav">
    <prop>
        <getetag />
        <c:address-data />
    </prop>
    <href>/1437425399/carddavhome/card/somecard.vcf</href>
    <href>/1437425399/carddavhome/card/anothercard.vcf</href>
</c:addressbook-multiget>

对于更新,创建和删除卡,您可以使用我们先前在将Content-Type设置为"text/vcard"之后讨论的基本身份验证,在"/1437425399/carddavhome/card/cardtobemanipulated.vcf"端点上触发PUT请求.并发送内容中的VCard以进行更新和创建请求.

For updating, creating and deleting cards, you can fire PUT requests at "/1437425399/carddavhome/card/cardtobemanipulated.vcf" endpoint using the basic authentication that we discussed earlier after setting the Content-Type as "text/vcard" and sending the VCard in the content for update and create requests.

这篇关于Apple iCloud访问UWP应用程序中的联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆