问题描述
我有一个使用 .NET 和 Contacts API 的已安装应用。我正在尝试转换为 People API。我在开始和查找展示如何使用 People API 和 .NET 库的示例时遇到问题。例如,Peoples API documentation 下列出的示例不包括 .NET。在哪里可以找到 People API 的 .NET 示例?
解决方法
从这个开始;)
获取名为 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();