【问题标题】:Google Contacts API v3 Java Client Library full text search is not workingGoogle Contacts API v3 Java 客户端库全文搜索不起作用
【发布时间】:2012-11-28 18:45:03
【问题描述】:

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

我已经下载了最新的 Java 客户端库:用于 GDATA 的 GData-Java/1.47.1(gzip)。尝试使用 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 更精细:授权:

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

2012 年 11 月 28 日下午 12:38:48 com.google.gdata.client.http.HttpGDataRequest setHeader 更精细:接受编码:gzip

2012 年 11 月 28 日下午 12:38:48 com.google.gdata.client.http.HttpGDataRequest setHeader 更精细:GData 版本:3.0

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 精细:403 禁止

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 执行 更精细:X 帧选项:SAMEORIGIN

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 更精细:传输编码:分块

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 更详细:日期:格林威治标准时间 2012 年 11 月 28 日星期三 17:38:48

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 更精细:到期:格林威治标准时间 2012 年 11 月 28 日星期三 17:38:48

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

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 更精细:内容编码:gzip

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 更精细:内容类型:文本/html; charset=UTF-8

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

2012 年 11 月 28 日 12:38:48 PM com.google.gdata.client.http.HttpGDataRequest 执行 更精细:缓存控制:私有,max-age=0

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

线程“主”com.google.gdata.util.ServiceForbiddenException 中的异常:禁止 此服务不支持 '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

【问题讨论】:

    标签: java api


    【解决方案1】:

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

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

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

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

    希望我有所帮助..

    【讨论】:

      【解决方案2】:

      这行得通:

      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 是全文搜索的必备项!

      【讨论】:

        猜你喜欢
        • 2012-12-15
        • 2014-09-08
        • 1970-01-01
        • 2020-01-01
        • 1970-01-01
        • 2014-12-09
        • 1970-01-01
        • 2019-08-01
        • 1970-01-01
        相关资源
        最近更新 更多