javascript Reddit 搜索 API 网址?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21458102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 20:58:01  来源:igfitidea点击:

Reddit Search API URL?

javascriptjsonapisearchreddit

提问by mickdeez

I'm trying to implement a search using reddit's api, but am not having much luck:

我正在尝试使用 reddit 的 api 实现搜索,但运气不佳:

http://www.reddit.com/search.json?q=ferrari?jsonp=?

It's returning some json formatted text but no results.. If I search "cars", it returns 2 results, and the rest of my code won't recognize the objects. (Plus, I know there's more than 2 results for cars). Any idea on how to modify the URL?

它返回一些 json 格式的文本,但没有结果。如果我搜索“汽车”,它会返回 2 个结果,而我的其余代码将无法识别这些对象。(另外,我知道汽车有 2 个以上的结果)。关于如何修改 URL 的任何想法?

回答by Theox

Your URL looks wrong. I think you used a question mark instead of an amp to separate request variables.

您的网址看起来有误。我认为您使用问号而不是放大器来分隔请求变量。

I tried using http://www.reddit.com/search.json?q=ferrariand I got a lot of results in JSON format.

我尝试使用http://www.reddit.com/search.json?q=ferrari,得到了很多 JSON 格式的结果。

This will allow you to do the most basic search for reddit posts.

这将允许您对 reddit 帖子进行最基本的搜索。

You can add other parameters, described on the reddit API page : http://www.reddit.com/dev/api#GET_search. You can also limit your search to one subreddit.

您可以添加其他参数,如 reddit API 页面所述:http: //www.reddit.com/dev/api#GET_search。您还可以将搜索限制为一个 subreddit。

For example, to get the same results, sort by newest : http://www.reddit.com/search.json?q=ferrari&sort=new

例如,要获得相同的结果,请按最新排序: http://www.reddit.com/search.json?q=ferrari&sort=new

回答by Petar Vasilev

It does work for me like so :

它确实对我有用:

http://www.reddit.com/search.json?q=rest&jsonp=callback

and there is limit parameter which by default is 25 and the maximum is 100

并且有限制参数,默认为 25,最大值为 100