Get contacts by phonenumber using gdata-contacts - java

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

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.

Related

Firestore : How to add a field to the auto generated id in firestore when user clicks on a button in android

I implemented the FCM notification to the user in Cloud Functions. By using Cloud Functions I added a document(auto generated id) into the Firestore. I need that document id to add another field as status in the same document from android app.
I had a database path like:
/deyaPayUser
{authid}
/Split
{auth id }
/Received Invitation
{auto id}
. Amount: 10
. PhoneNumber:987654321
These is the data already exist . Now I need to add a field in that document. How to get the current document id of the user
Status : true
According to your comments, in order to find that particular document, you need to create a Query based on property within that document like this:
Query query = yourCollectionReference.whereEqualTo("PhoneNumber", 987654321);
This query will find the user that has the phone number 987654321.
Now just simply use a get() call, get the id and make the update:
Map<String, Object> map = new HashMap<>();
map.put("Status", true);
yourCollectionReference.document(documentId).update(map);

How to update test results in rally api by providing test set name

I tried with the code in the below previous post .
How to get TestSet ID using Rally Rest API in Java?
i am able to update test results in rally api by providing test set id ,but when I provide test set name , i am getting null pointer exception. I am able to retrieve the test set id for first two iterations , but when creating test case ,test set is null . Do i need to change query parameter ? ,. Can anyone please help me on this.
There are a few updates to the code you provided that allow getting this information. The updates are:
QueryRequest testsetRequest = new QueryRequest("TestSet");
testsetRequest.setFetch(new Fetch("FormattedID","Name"));
testsetRequest.setQueryFilter(new QueryFilter("Name", "=", "TestSetName"));
QueryResponse testSetQueryResponse = restApi.query(testsetRequest);
System.out.println(String.format("\nTestSet: %d",testSetQueryResponse.getTotalResultCount()));
String TestSetref = testSetQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").toString();
System.out.println(TestSetref);

get only new contacts from google contacts api

I want to make a query to Google contacts that retrieves all NEW contacts since a given Date.
I am using google contacts api with the following scope: https://www.google.com/m8/feeds/
When I try to make a query that contains publishedMin parameter:
URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
Query myQuery = new Query(feedUrl);
myQuery.setPublishedMin(startDateTime);
myQuery.setMaxResults(1000);
ContactFeed resultFeed = service.getFeed(myQuery, ContactFeed.class);
I get the following error:
com.google.gdata.util.ServiceForbiddenException: Forbidden
This service does not support the 'published-min' parameter.
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:605)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
at com.google.gdata.client.Service.getFeed(Service.java:1077)
How else can I get the new contacts since a given date if I cannot use publishedMin.
Is there an alternative or a workaround for this?
I tried using updatedMin and then search every contact for getPublished() to filter them out but all the values are null.
Thanks in advance.
The Google Contacts API does not support a "published-min" parameter. Out of curiosity, where did you find this Java library that is still trying to use it? (if it is the latest version of a Google-provided library then it ought to be updated)
In the mean time, what you are looking for is the updated-min parameter:
https://developers.google.com/google-apps/contacts/v3/#retrieving_contacts_using_query_parameters

How to convert friend id's to corresponding name in twitter using twitter4j?

Here I'm able to get all friends ids. But for the same I need to get name of corresponding id. How can I get it? For getting friends ids I'm using Twitter4j lib and my code is:
String friendsIds = twitter.getFriendsIDs(MyId, cursor).toString();
For this output is:
friendsIds:IDsJSONImpl{ids=[43347766, 2369925598, 238933377, 243381784, 946613156, 541261639], previousCursor=0, nextCursor=0}
How can I get names for those ids?
You can use lookupUsers(long[]) to bulk retrieve your friends and get access to their screen names, e.g.:
final IDs friendIds = twitter.getFriendsIDs(MyId, cursor);
final ResponseList<User> users = twitter.lookupUsers(friendIds.getIDs());
for (User u : users) {
System.out.println(u.getScreenName());
}
Note that you can retrieve up to a maximum of 100 users at a time using the lookupUsers API call, so you may have to split the ids up if you have more than 100 friends.

Search twitter by language

In twitter by using lang operator you can search for retrieving tweets from a particular language: For example, the following search will return tweets only in english:
https://twitter.com/search?q=lang:en
Is there a way to achieve this using twitter api, especially using twitter4j. I know there is a language attribute for search but it also requires at least one keyword to make a search, I would like to search by a particular language without giving any keyword query. The following command in java driver returns the following error:
Query searchQuery = new Query() //
.count(resultsPerPage) //
.since(since)//
.lang("en");
400:The request was invalid. An accompanying error message will explain why. This is the status code will be returned during version 1.0 rate limiting(https://dev.twitter.com/pages/rate-limiting). In API v1.1, a request without authentication is considered invalid and you will get this response.
message - Query parameters are missing
code - 25
Cheers
You must pass the same do you use in the twitter search, your query will be like:
new Query("lang:en")
Using twitter4j,
Query query = new Query();
query.setLang("en");
query.setQuery(searchQuery);

Categories