【问题标题】:Faraday - Multiple GET param request to Freebase APIFaraday - 对 Freebase API 的多个 GET 参数请求
【发布时间】:2012-12-13 23:11:38
【问题描述】:

我一直在尝试从 Freebase API 获取主题信息。无论如何,这主要是一个 Ruby Faraday 问题。

所以我在以下路径请求: https://www.googleapis.com/freebase/v1/topic/m/02676m4?limit=20&filter=/film/film_series/films_in_series&filter=/common/topic/article

注意有两个 &filter。使用我的网络浏览器可以正常工作。但是,在 Ruby 上执行以下任一操作时:

response = Faraday.get 'https://www.googleapis.com/freebase/v1/topic/m/02676m4', {
        'limit' => 20,
        'filter' => ['/film/film_series/films_in_series', '/common/topic/article'],
        'key' => 'my_key_here'
    }, { 'Accept' => self.Headers_Accept }

或者...

response = Faraday.get 'https://www.googleapis.com/freebase/v1/topic/m/02676m4', {
        'limit' => 20,
        'filter' => '/film/film_series/films_in_series&filter=/common/topic/article',
        'key' => 'my_key_here'
    }, { 'Accept' => self.Headers_Accept }

或者...

response = Faraday.get 'https://www.googleapis.com/freebase/v1/topic/m/02676m4?limit=20&filter=/film/film_series/films_in_series&filter=/common/topic/article&key=my_key_here', {}, { 'Accept' => self.Headers_Accept }

然后过滤器会被 API 忽略。我收到与我的主题相关的每一条信息的巨大响应。

您可以通过不使用过滤器执行查询来复制结果: https://www.googleapis.com/freebase/v1/topic/m/02676m4?limit=20

问题: 任何人都可以想出一个原因,为什么我通过 Faraday 遇到这个问题,但直接通过我的浏览器访问时却没有?

额外提示: 如果我只对法拉第请求使用 one 过滤器,它就可以正常工作。但我确实需要使用多个过滤器。

Freebase 主题 API: http://wiki.freebase.com/wiki/Topic_API

谢谢!

【问题讨论】:

    标签: ruby freebase faraday


    【解决方案1】:

    这听起来很像这个拉取请求修复的法拉第错误:https://github.com/technoweenie/faraday/pull/199

    【讨论】:

    • 嗯,这样解决了吗?还是我需要提供一些额外的参数以便它适用于我的情况?
    猜你喜欢
    • 1970-01-01
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    相关资源
    最近更新 更多