2016-09-29 130 views
0

我想向Google聯繫人發送查詢,該聯繫人會在給定日期後檢索所有新聯繫人。從google聯繫人api獲取新聯繫人

我使用谷歌聯繫人API具有以下範圍:https://www.google.com/m8/feeds/

當我嘗試做一個包含publishedMin參數的查詢:

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); 

我收到以下錯誤:

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) 

如果我不能使用publishedMin,我還能如何從給定日期後獲得新聯繫人。 是否有替代方案或解決方法?

我嘗試使用updatedMin,然後搜索每個聯繫人getPublished()將其過濾掉,但所有值都是null

在此先感謝。

+0

您是否嘗試過更新您的Java API庫?我猜目前的版本不支持請求不贊成API的功能(如published-min)。也許你需要一個潛在的變化。 – LinuxDisciple

+0

我正在使用最新的1.22版本的API。所以不是這樣。 – aleksandar

回答

0

Google Contacts API不支持「published-min」參數。出於好奇,你在哪裏發現這個仍在嘗試使用它的Java庫? (如果是谷歌提供的庫的最新版本,那麼它應該被更新)

與此同時,你正在尋找的是updated-min參數: https://developers.google.com/google-apps/contacts/v3/#retrieving_contacts_using_query_parameters

+0

但這就是我的問題的全部:如果你使用updatedMin,那麼你同時得到更新的聯繫人和新的聯繫人。我只想要新的聯繫人,我不能說他們分開。 – aleksandar

+0

對不起,我誤解了。創建時間不會與上次更新時間分開跟蹤,因此無法專門查詢。 –