【问题标题】:Where to find sample C# .NET code for Google's People API?在哪里可以找到 Google 人员 API 的示例 C# .NET 代码?
【发布时间】:2021-05-30 14:15:56
【问题描述】:

我有一个使用 .NET 和联系人 API 的已安装应用程序。我正在尝试转换为 People API。我在入门和查找显示如何将 People API 与 .NET 库一起使用的示例时遇到了麻烦。例如,Peoples API documentation 下列出的示例不包括 .NET。在哪里可以找到 People API 的 .NET 示例?

【问题讨论】:

标签: google-people-api


【解决方案1】:

从这里开始 ;)

https://googleapis.dev/dotnet/Google.Apis.PeopleService.v1/latest/api/Google.Apis.PeopleService.v1.html

获取名为 Google.Apis.PeopleService.v1 https://github.com/googleapis/google-api-dotnet-client的 nuget

另外,我相信你已经看过这个https://developers.google.com/people/v1/profiles 它有一些 .net 示例。

您到底想完成什么? 我即将使用公司的服务帐户完成将使用联系人 API 的应用程序转换为人员 API 的应用程序。

ps。我无法通过链接复制答案中的整个命名空间。

编辑:20210608

        Person person = new Person();

        person.EmailAddresses = new List<EmailAddress>();
        person.EmailAddresses.Add(new EmailAddress() { Type = "work", Value = "sample@domain.com" });
        person.Names = new List<Name>();
        person.Names.Add(new Name() { FamilyName = "Lname2", GivenName = "Fname" });

        // link to peopleService code can be found in the comments
        // it's basically initializing PeopleServiceService with service account credentials
        Person retVal = peopleService.People.CreateContact(person).Execute();

【讨论】:

  • 感谢 Zunair。是的,我确实看到了命名空间文档。我正在寻找一些示例 .NET 代码,这些代码展示了如何对联系人和组进行一些基本操作。我正在从文档中弄清楚,但我发现一些示例代码非常有用,尤其是在开始时。我正在将 Windows 通讯簿同步到 Google 联系人。
  • 服务初始化见此stackoverflow.com/questions/50385783/… 我将添加一个小示例来创建用户 - 我只使用 Batch 类,如果您打算修改大量数据,请使用它。
  • 这里是批量请求代码stackoverflow.com/questions/63598523/…的链接
  • @Zunair,我试图检索批处理请求的状态,但似乎都是空值。您是否尝试过从 PeopleResponse 读取 Status 属性?
  • 我刚刚更新了批处理请求代码 - 我没有展示如何执行批处理请求:facepalm
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-09
  • 1970-01-01
  • 1970-01-01
  • 2010-10-12
  • 1970-01-01
  • 2011-01-17
相关资源
最近更新 更多