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

标签 javascript json api

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

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 是我出于明显原因替换的 api key 。 “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=####通常方括号表示可选参数。我敢打赌,如果您删除这些内容,它实际上会理解您发送的内容并工作。

关于javascript - 来自纽约时报 API (JSON) 的查询在不同的搜索关键字上给出相同的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29854888/

相关文章:

javascript - float 中的绝对定位元素

Javascript AJAX PHP if 语句不起作用

javascript - Google API - 未找到文件 ID - 但返回的数据对应于我输入的folderId

api - 我可以通过亚马逊的 API 获得打折的产品吗?

javascript - 如何检查 goBack() 函数在 react 导航中是否可行?

mysql - 将 MySQL JSON 列数组读取为行

python - 流式 json 解析器

java - 将 javax json 从 1.0.2 更新到 1.1

javascript - 在 http 请求之前检查访问 token

javascript - 带有 3 个文本字段的计算器,只写在焦点 jquery 的字段上