简体   繁体   中英

Google Contacts API - how to filter only email contacts

This is the java-script sample code I am using.

<script type="text/javascript">
  function auth() {
    var config = {
      'client_id': 'your client ID HERE',
      'scope': 'https://www.google.com/m8/feeds'
    };
    gapi.auth.authorize(config, function() {
      fetch(gapi.auth.getToken());  

    });
  }

  function fetch(token) {
    $.ajax({
        url: "https://www.google.com/m8/feeds/contacts/default/full?access_token=" + token.access_token + "&alt=json",
        dataType: "jsonp",
        success:function(data) {
                          // display all your data in console
                  console.log(JSON.stringify(data));
        }
    });
}   

But this is importing both email contacts and phone contacts. Is there any option to filter in javascript to get ONLY the email contacts ?

Currently I am filtering after importing both contacts from Google .

Any help will be appreciable.

Please Note: This is not a duplicate question. Similar questions are available in stackoverflow, but are not exactly suitable for my needs.

I googled and looked around the community for quite some time but didn't find anything that serves as a direct filter that you can add in your request only to filter out email contacts. What I suggest you could do though is to group your email contacts, then retrieve the contact group by using the group parameter.

Don't know if this might be useful for you, but gonna go on ahead and include it here, be mindful about using both the query and group parameters together, found this post that says that they don't work together.

Hope this helps you somehow. Good luck.

You can use q=@ in your query. It means it makes a textual search of the letter "@" in every field, and as such returns (almost) only results with email addresses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM