【问题标题】:Is there a way to bypass the required attribute "term" in the iTunes search API?有没有办法绕过 iTunes 搜索 API 中所需的属性“术语”?
【发布时间】:2016-01-13 22:21:17
【问题描述】:

我正在将 iTunes 搜索 API(更具体地说是 this gem 用于 rails)用于查询的最重要部分是类型的应用程序。我有一个清单,用户可以在其中选择某种流派,并且将在查询中搜索匹配的流派 ID。但是,我无法弄清楚在 term 字段中放置什么将适用于所有返回的结果,并且我不能省略该属性,因为它是必需的。如果我输入流派的名称,例如“技术”,则只返回标题或艺术家名称中带有“技术”一词的播客,这并不理想。

ITunesSearchAPI.search(:term=> "????", :genreId=> @genre_id , :country => "US", :entity=> "podcast", :media => "podcast", :limit => 15)

我尝试了“+”,因为根据iTunes search API documentation,“URL 编码用加号 (+) 字符替换空格”。我也尝试过“播客”,它产生与上述相同的问题。有什么办法可以解决这个问题?

【问题讨论】:

    标签: ruby-on-rails api itunes itunes-search-api


    【解决方案1】:

    你不能绕过term,因为它是必需的参数。

    要制作 url 编码的字符串,您需要使用 URI::encode('string') 方法。

    像这样:

    require 'open-uri'
    ITunesSearchAPI.search(:term=> URI::encode('Super mega podcast'), :genreId=> @genre_id , :country => "US", :entity=> "podcast", :media => "podcast", :limit => 15)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 2011-12-11
      • 1970-01-01
      相关资源
      最近更新 更多