如何创建谷歌联系人?
我正在尝试与谷歌Gmail联系人集成我按照这个示例谷歌联系人API版本3.0我收到此错误执行请求失败: https : //www.google.com/m8/feeds/contacts/default/full
Google.Contacts.Contact createdEntry = cr.Insert(feedUri, newEntry);
内心期望:
{“远程服务器返回错误:(400)错误请求。”}
[第12行,第127列,元素gd:im]缺少属性:’地址’
完整的代码
using Google.Contacts; using Google.GData.Contacts; using Google.GData.Client; using Google.GData.Extensions; RequestSettings settings = new RequestSettings("OVI2GoogleContacts", "my email", "pass"); ContactsRequest cr = new ContactsRequest(settings); Google.Contacts.Contact newEntry = new Google.Contacts.Contact(); // Set the contact's name. newEntry.Name = new Name() { FullName = "Elizabeth Bennet", GivenName = "Elizabeth", FamilyName = "Bennet", }; newEntry.Content = "Notes"; //Set the contact's e-mail addresses. newEntry.Emails.Add(new EMail() { Primary = true, Rel = ContactsRelationships.IsHome, Address = "lizgmail.com" }); newEntry.Emails.Add(new EMail() { Rel = ContactsRelationships.IsWork, Address = "lizexample.com" }); //Set the contact's phone numbers. newEntry.Phonenumbers.Add(new PhoneNumber() { Primary = true, Rel = ContactsRelationships.IsWork, Value = "(206)555-1212", }); newEntry.Phonenumbers.Add(new PhoneNumber() { Rel = ContactsRelationships.IsHome, Value = "(206)555-1213", }); // Set the contact's IM information. newEntry.IMs.Add(new IMAddress() { Primary = true, Rel = ContactsRelationships.IsHome, Protocol = ContactsProtocols.IsGoogleTalk, }); // Set the contact's postal address. newEntry.PostalAddresses.Add(new StructuredPostalAddress() { Rel = ContactsRelationships.IsWork, Primary = true, Street = "1600 Amphitheatre Pkwy", City = "Mountain View", Region = "CA", Postcode = "94043", Country = "United States", FormattedAddress = "1600 Amphitheatre Pkwy Mountain View", }); // Insert the contact. Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default")); Google.Contacts.Contact createdEntry = cr.Insert(feedUri, newEntry); // here the error
Google自己的示例代码似乎无效。 根据文档Google Data type / kind gd:im要求填充属性地址 。
@地址
@标签?
@rel?
@协议?
@主?
约定:
elementName必需元素
elementName ? 可选元素
elementName *****可选元素,允许多个实例
您需要更新部分代码,例如:
newEntry.IMs.Add(new IMAddress() { Address = "email@dot.com", // untested Primary = true, Rel = ContactsRelationships.IsHome, Protocol = ContactsProtocols.IsGoogleTalk, });
问题是在Erik上面建议的联系人条目中添加IM …在google api示例中,他们错过了提及IM地址
只需添加Address =“liz@gmail.com”即可
上述就是C#学习教程:如何创建谷歌联系人?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
// Set the contact's IM information. newEntry.IMs.Add(new IMAddress() { Primary = true, Rel = ContactsRelationships.IsHome, Protocol = ContactsProtocols.IsGoogleTalk, **Address = "liz@gmail.com",** });
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1010110.html