使用Google通讯录API和.Net获取电话号码标签

时间:2014-06-10 19:30:42

标签: c# google-contacts google-shared-contacts

我正在尝试使用以下代码检索来自Google的相应标签的电话号码。

        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”,但这些值未被退回。我在这里错过了什么吗?

1 个答案:

答案 0 :(得分:0)

Contacts API使用标准标签的rel属性:

自定义标签保存在label属性中,这两个属性互为独占described here