3

I am trying to get contact name, email and phone from google contact api from contact feed http://www.google.com/m8/feeds/contacts/default/full

var entries = result.feed.entry;

for (var i = 0; i < entries.length; i++) {
    var contactEntry = entries[i];
    var emailAddresses = contactEntry.getEmailAddresses();

    for (var j = 0; j < emailAddresses.length; j++) {
        var emailAddress = emailAddresses[j].getAddress();
        vemail += emailAddress + ',';
    }

     var fname = contactEntry.getPhoneNumbers();

    if (phoneNumbers.length == 0) {
        console.log('phone number = N/A');
    } else {         
        for (var j = 0; j < phoneNumbers.length; j++) {
            var phoneNumber = phoneNumbers[j].getValue() || 'N/A';
            console.log('phone number = ' + phoneNumber);
        }
    }
}

I can get phone number and email from the code above. May I know how to get the name too? Thanks

Kara
  • 6,115
  • 16
  • 50
  • 57
davidlee
  • 5,611
  • 17
  • 56
  • 82

1 Answers1

6

Contact name is stored in contactEntry.title.$t, you can get it using contactEntry.getTitle().getText();

Reference: http://www.mycodeland.com/?p=25

P.S. you can also try console.log(contactEntry) in chrome. This will output the whole contact object for you in console so you can browse through it's properties and methods.

Dr. Rajesh Rolen
  • 14,029
  • 41
  • 106
  • 178
valentinas
  • 4,277
  • 1
  • 20
  • 27