3

Contacts API v3,群组查询参数不支持'q'参数???在 Google Contacts API v3 中,它明确表示支持。但是,当我使用谷歌提供的 java 客户端库,通过 setFullTextQuery 在查询中搜索合同组时,我得到 HTTP 状态 403 Forbidden。抛出“线程“主”com.google.gdata.util.ServiceForbiddenException 中的异常:禁止此服务不支持“q”参数。”

我已经下载了最新的 Java 客户端库:GData-Java/1.47.1(gzip) for GDATA。尝试使用 setFullTextQuery 方法搜索联系人组。

哪些步骤将重现该问题?

  1. 设置 Java 示例联系人
  2. 在 ContactsExample.java 中的 queryEntries 方法中,添加一个新行。myQuery.setFullTextQuery("你的搜索词在这里");
  3. 并运行它

我检查了版本是否正确,它使用的是 GData-Version: 3.0 如果按照提供的方式运行示例 java,一切运行正常。但是,我需要搜索联系人。并且使用 'q' 参数应该是正确的方法。

请帮忙。是图书馆出了什么问题,还是我需要采取不同的方法来搜索联系人?

下面的日志:

执行动作:QUERY

2012 年 11 月 28 日下午 12:38:48 com.google.gdata.client.http.HttpGDataRequest setPrivateHeader FINER:授权:

2012 年 11 月 28 日下午 12:38:48 com.google.gdata.client.http.HttpGDataRequest setHeader FINER:用户代理:Google-contactsExampleApp-3 GContacts-Java/3.1.0 GData-Java/1.47.1(gzip)

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest setHeader FINER: Accept-Encoding: gzip

2012 年 11 月 28 日下午 12:38:48 com.google.gdata.client.http.HttpGDataRequest setHeader FINER: GData-Version: 3.0

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINE:403 Forbidden

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINER: null: HTTP/1.1 403 Forbidden

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINER: X-Frame-Options: SAMEORIGIN

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINER: Transfer-Encoding: chunked

2012 年 11 月 28 日下午 12:38:48 com.google.gdata.client.http.HttpGDataRequest 执行更精细:日期:2012 年 11 月 28 日星期三 17:38:48 GMT

2012 年 11 月 28 日下午 12:38:48 com.google.gdata.client.http.HttpGDataRequest 执行 FINER: Expires: Wed, 28 Nov 2012 17:38:48 GMT

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINER: X-XSS-Protection: 1; 模式=块

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINER: Content-Encoding: gzip

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINER: Content-Type: text/html; 字符集=UTF-8

2012 年 11 月 28 日下午 12:38:48 com.google.gdata.client.http.HttpGDataRequest 执行更精细:服务器:GSE

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINER: Cache-Control: private, max-age=0

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 FINER: X-Content-Type-Options: nosniff

线程“main”中的异常 com.google.gdata.util.ServiceForbiddenException: Forbidden 此服务不支持“q”参数。

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)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:676)
at com.google.gdata.client.Service.query(Service.java:1237)
at com.google.gdata.client.Service.query(Service.java:1178)
at sample.contacts.ContactsExample.queryEntries(ContactsExample.java:406)
at sample.contacts.ContactsExample.processAction(ContactsExample.java:350)
at sample.contacts.ContactsExample.main(ContactsExample.java:626)

Java 结果:1

4

2 回答 2

0

这里只是一个长镜头,因为你还没有发布任何代码......

似乎您尚未进行身份验证并设置执行查询的用户。

IE 您可能需要在查询中添加以下内容:

myQuery.addCustomParameter(
    new Query.CustomParameter("xoauth_requestor_id"
        , username)); //where username is the authenticated (probably by OAuth) user

希望我帮助..

于 2013-01-28T12:45:25.380 回答
0

这有效:

https://www.google.com/m8/feeds/contacts/default/full?v=3.0&alt=json&q=john&max-results=10&orderby=lastmodified&sortorder=descending

请注意,这v=3.0是全文搜索的必备条件!

于 2016-09-03T08:09:26.797 回答