来自纽约时报 API (JSON) 的查询在不同的搜索关键字上给出相同的输出?

Query from New York Times API (JSON) giving same output on different search keywords?

我正在尝试从您的新时代 API 获取 JSON 数据。下面是我正在使用的查询。它是根据他们网站上的示例查询编辑的。

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 是 api 键,我出于显而易见的原因替换了它。 "search_city_name" = 据我所知,我应该将搜索关键字放在的位置。

问题:无论我尝试在查询中搜索什么,我都会得到相同的结果。 查询:

http://api.nytimes.com/svc/search/v2/articlesearch.json?q="search_city_name"&sort=newest&&api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

例如,这是我得到的响应数组的第一个对象,无论我粘贴什么字符串而不是 "search_city_name":

_id: "553a537238f0d87fad3b3cd7"
abstract: null
blog: Array[0]
byline: Object
document_type: "article"
headline: Object
keywords: Array[1]
lead_paragraph: "Cokie Roberts’s “Capital Dames,” No. 10 on the hardcover nonfiction list, is about powerful women in Washington during the Civil War era."
multimedia: Array[2]
news_desk: "BookReview"
print_page: "26"
pub_date: "2015-05-03T00:00:00Z"
section_name: "Books"
snippet: "Cokie Roberts’s “Capital Dames,” No. 10 on the hardcover nonfiction list, is about powerful women in Washington during the Civil War era."
source: "The New York Times"
subsection_name: "Sunday Book Review"
type_of_material: "News"
web_url: "http://www.nytimes.com/2015/05/03/books/review/inside-the-list.html"
word_count: "480"

更新: 查询的工作版本:

"http://api.nytimes.com/svc/search/v2/articlesearch.json?q="+ city +"&&api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxx"

docs中给出的例子是http://api.nytimes.com/svc/search/v2/articlesearch.response-format?[q=search term&fq=filter-field:(filter-term)&additional-params=values]&api-key=#### 通常方括号表示可选参数。我敢打赌,如果您删除它们,它就会真正理解您发送的内容并开始工作。

您是否使用 Get 方法从 API 获取数据,然后它会为您提供上次调用的缓存数据,

因此请使用 "post" 而不是 get 或针对特定请求使缓存为 false。