使用Google Contacts API和.Net获取电话号码标签 [英] Get phone number label using Google Contacts API and .Net
本文介绍了使用Google Contacts API和.Net获取电话号码标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下代码从Google检索带有相应标签的电话号码.
I'm trying to retrieve phone numbers with respective labels from Google with the following code.
RequestSettings settings = new RequestSettings("myapp", username, password){
UseSSL = true,
AutoPaging = true,
PageSize = 5000
};
ContactsRequest c = new ContactsRequest(settings);
Feed<Contact> feed = c.GetContacts();
foreach (var entry in feed.Entries)
{
foreach (PhoneNumber phoneNumber in entry.Phonenumbers){
Debug.Write(phoneNumber.Label ?? "Empty"); //Always null!
Debug.Write(phoneNumber.Value ?? "Empty");//Have value
}
}
但是,我已经在Google帐户中的电话号码上设置了标签,例如"Home","Movile",但这些值未返回.我在这里想念东西吗?
However, I had set label to the phone numbers in my Google account such as "Home", "Movile", but those values are not been returned. Am I missing something here?
推荐答案
Contacts API使用rel
属性作为标准标签:
The Contacts API uses the rel
attribute for standard labels:
- 首页: http://schemas.google.com/g/2005#home
- 工作: http://schemas.google.com/g/2005#work
- 其他: http://schemas.google.com/g/2005#other
- Home: http://schemas.google.com/g/2005#home
- Work: http://schemas.google.com/g/2005#work
- Other: http://schemas.google.com/g/2005#other
自定义标签保存在label
属性中,并且这两个属性互斥为在此描述.
Custom labels are held in the label
attribute, and these two attributes are mutually exclusive as described here.
这篇关于使用Google Contacts API和.Net获取电话号码标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文