简体   繁体   English

法拉第-对Freebase API的多个GET参数请求

[英]Faraday - Multiple GET param request to Freebase API

I am stuck trying to get Topic information from the Freebase API. 我一直试图从Freebase API获取主题信息。 This is mostly a Ruby Faraday question anyways. 无论如何,这主要是一个Ruby Faraday问题。

So I request at the following path: https://www.googleapis.com/freebase/v1/topic/m/02676m4?limit=20&filter=/film/film_series/films_in_series&filter=/common/topic/article 因此,我在以下路径中请求: https : //www.googleapis.com/freebase/v1/topic/m/02676m4?limit=20&filter=/film/film_series/films_in_series&filter=/common/topic/article

Notice how there are TWO &filter. 注意如何有两个&filter。 This works just fine using my web browser. 使用我的网络浏览器可以正常工作。 When doing either the following on Ruby, though: 但是,在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 }

or... 要么...

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 }

or... 要么...

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 }

Then Filters are ignored by the API. 然后,API将忽略过滤器。 I get a huge response with every single piece of information regarding my topic. 关于我的主题的每一条信息,我都会得到巨大的回应。

You can replicate the result by performing the query with no filters : https://www.googleapis.com/freebase/v1/topic/m/02676m4?limit=20 您可以通过不使用过滤器执行查询来复制结果: https : //www.googleapis.com/freebase/v1/topic/m/02676m4?limit=20

Question: Anyone can come up with a reason why I get this issue through Faraday, but not when accessing directly through my browser? 问题:任何人都可以提出我通过法拉第解决此问题的原因,但是不能直接通过浏览器访问时解决此问题的原因吗?

Extra tip: If I only use one filter on the Faraday request, it works just fine. 额外提示:如果我仅在法拉第请求中使用一个过滤器,则效果很好。 But I really need to use more than one filter. 但是我确实需要使用多个过滤器。

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

Thanks! 谢谢!

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM