Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6165263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:08:08+00:00 2026-05-23T22:08:08+00:00

I’m using code from this page http://code.google.com/apis/contacts/docs/1.0/developers_guide_js.html to get list of gmail contacts. Actually

  • 0

I’m using code from this page http://code.google.com/apis/contacts/docs/1.0/developers_guide_js.html to get list of gmail contacts. Actually it works ok, but I get data of name, address, etc like a simple string, with “\n” as separator, for example:

<script type="text/javascript">
    var contactsService;
    var scope = 'https://www.google.com/m8/feeds';

    function setupContactsService() {
      //contactsService = new google.gdata.contacts.ContactsService('exampleCo-exampleApp-1.0');
      contactsService = new google.gdata.contacts.ContactsService('GoogleInc-jsguide-1.0');
    }

    function getMyContacts() {
      var contactsFeedUri = 'https://www.google.com/m8/feeds/contacts/default/full'; //?max-results=9999&alt=json&v=3.0
      var query = new google.gdata.contacts.ContactQuery(contactsFeedUri);

      setupContactsService();

      contactsService.getContactFeed(query, handleContactsFeed, handleError);

    }

    var handleContactsFeed = function(result) {
      var entries = result.feed.entry;

      for (var i = 0; i < entries.length; i++) {
        var entry = entries[i];
        var addrs  = entry.getPostalAddresses();
        var name   = entry.getTitle();

        // logging
        console.log(addrs[0]);
        console.log(name);

      }
    }

    function handleError(e) {
      alert(e.cause ? e.cause.statusText : e.message);
    }
</script>

it gives me an object where name and address values are simple strings.

Can I get somehow data in like associative array format, where address will contains separate values of street, zip, city, country; and name separate values of first name, last name etc.

Like:

{
     "type": "address",  
     "value":  
       {  
        "street": "Starret 1234",  
        "city": "City name",  
        "stateOrProvince": "ca",  
        "postalCode": "73000",  
        "country": "USA"
     }
},
{
    "type": "name",
    "value":
    {
        "firstName": "Allen",
        "lastName" : "Iverson",
        .....
    }
}

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:08:08+00:00Added an answer on May 23, 2026 at 10:08 pm

    Seems I found an answer, for get more detailed and formatted info need to add additional parameter to contactsFeedUri for google.gdata.contacts.ContactQuery.

    This additional parameter is: ?v=3.0
    So in my case function will looks like:

    function getMyContacts() {
          var contactsFeedUri = 'https://www.google.com/m8/feeds/contacts/default/full?v=3.0&alt=json';
          var query = new google.gdata.contacts.ContactQuery(contactsFeedUri);
    
          setupContactsService();
    
          contactsService.getContactFeed(query, handleContactsFeed, handleError);
    
        }
    

    And for get necessary data I create a simple obj, which can be useful for somebody:

    function contactEntry(entry) {
            this.entry = entry;
            this.testEntry = function() {
                alert( 'test entry' )
            };
            this.getFirstName = function() {
                if ((entry.gd$name == null) || (entry.gd$name.gd$givenName == null) || (entry.gd$name.gd$givenName.$t == null)) {
                    return '';
                } else {
                    return entry.gd$name.gd$givenName.$t;
                }
            };
            this.getLastName = function() {
                if ((entry.gd$name == null) || (entry.gd$name.gd$familyName == null) || (entry.gd$name.gd$familyName.$t == null)) {
                    return '';
                } else {
                    return entry.gd$name.gd$familyName.$t;
                }
            };
            this.getAdditionalName = function() {
                if ((entry.gd$name == null) || (entry.gd$name.gd$AdditionalName == null) || (entry.gd$name.gd$AdditionalName.$t == null)) {
                    return '';
                } else {
                    return entry.gd$name.gd$familyName.$t;
                }
            };
            this.getEmail = function() {
                if ((entry.gd$email == null) || (entry.gd$email.length == 0) || (entry.gd$email[0].address == null)) {
                    return '';
                } else {
                    return entry.gd$email[0].address;
                }
            };
            this.getStreet = function() {
                if (!this._addrExists() || (entry.gd$structuredPostalAddress[0].gd$street == null)) {
                    return '';
                } else {
                    return entry.gd$structuredPostalAddress[0].gd$street.$t;
                }
            };
            this.getCity = function() {
                if (!this._addrExists() || (entry.gd$structuredPostalAddress[0].gd$city == null)) {
                    return '';
                } else {
                    return entry.gd$structuredPostalAddress[0].gd$city.$t;
                }
            };
            this.getCountry = function() {
                if (!this._addrExists() || (entry.gd$structuredPostalAddress[0].gd$country == null)) {
                    return '';
                } else {
                    return entry.gd$structuredPostalAddress[0].gd$country.$t;
                }
            };
            this.getPostcode = function() {
                if (!this._addrExists() || (entry.gd$structuredPostalAddress[0].gd$postcode == null)) {
                    return '';
                } else {
                    return entry.gd$structuredPostalAddress[0].gd$postcode.$t;
                }
            };
            this.getPhone = function() {
                if ((entry.gd$phoneNumber == null) || (entry.gd$phoneNumber.length == 0) || (entry.gd$phoneNumber[0].$t == null)) {
                    return '';
                } else {
                    return entry.gd$phoneNumber[0].$t
                }
            };
            this.getOrganization = function() {
                if ((entry.gd$organization == null) || (entry.gd$organization.length == 0) || (entry.gd$organization[0].getOrgName() == null)) {
                    return '';
                } else {
                    return entry.gd$organization[0].getOrgName().getValue();
                }
            };
            this.getBirthday = function() {
                if ((entry.gContact$birthday == null) || (entry.gContact$birthday.when == null)) {
                    return '';
                } else {
                    return entry.gContact$birthday.when;
                }
            };
            this.getEvent = function() {
                if ((entry.gContact$event == null) || (entry.gContact$event.length == 0) || (entry.gContact$event[0].gd$when == null)) {
                    return '';
                } else {
                    return entry.gContact$event[0].gd$when.startTime;
                }
            };
            // protected methods
            this._addrExists = function() {
                if ((entry.gd$structuredPostalAddress == null) || (entry.gd$structuredPostalAddress.length == 0)) {
                    return false;
                }
    
                return true;
            };
        } 
    

    It can be used in this way:

    var handleContactsFeed = function(result) {
    
          var entries = result.feed.entry;
    
          var contact = new contactEntry(entries[0]);
    
                    var address = {};
            address['fname']   = contact.getFirstName();
            address['lname']   = contact.getLastName() + (contact.getAdditionalName() != '' ? ' ' + contact.getAdditionalName() : '');
            address['address'] = contact.getStreet();
            address['city']    = contact.getCity();
            address['country'] = contact.getCountry();
            address['zip']     = contact.getPostcode();
            address['phone']   = contact.getPhone();
            address['mail']    = contact.getEmail();
            address['organization'] = contact.getOrganization();
            address['birthday'] = contact.getBirthday();
            address['event']   = contact.getEvent();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.