Search code examples
javagdatagoogle-contacts-api

Get contacts by phonenumber using gdata-contacts


I am trying to use Contacts query parameters reference. See https://developers.google.com/google-apps/contacts/v3/reference#contacts-query-parameters-reference

I am building the query like this:

URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");

Query query = new Query(feedUrl);

query.setMaxResults(1111);

query.setStringCustomParameter("phoneNumber", "123456789");

But Google API is returning all contacts while I just want the contact who has the 123456789 number.

Is it possible to get a google contact by phone number?

thanks


Solution

  • Try changing query to https://www.google.com/m8/feeds/contacts/default/full?q="6785555455" . I tried this in oauth playground and was able to retrieve contact who has matching phone number 6785555455. Here is the response:

    <gd:name>
      <gd:fullName>Hello</gd:fullName>
      <gd:givenName>Hi</gd:givenName>
    </gd:name>
    <gd:phoneNumber rel="http://schemas.google.com/g/2005#mobile"  uri="tel:+91-1234-222-321">(678)-555-5455</gd:phoneNumber>
    <gContact:groupMembershipInfo deleted="false"    href="http://www.google.com/m8/feeds/groups/guntupalliswathi%40gmail.com/b  ase/6"/>
    </entry>
    </feed>
    

    check this link for reference.