简体   繁体   中英

Faraday - Multiple GET param request to Freebase API

I am stuck trying to get Topic information from the Freebase API. This is mostly a Ruby Faraday question anyways.

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

Notice how there are TWO &filter. This works just fine using my web browser. When doing either the following on Ruby, though:

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. 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

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

Thanks!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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