打开浏览器中打印的application/json类型
Foursquare 的 api 可以选择搜索场地。 它是一个 HTTP GET 方法,具有以下形式:
https://api.foursquare.com/v2/venues/search?ll=40.7,-74&oauth_token=xxxx
在 Foursquare 的示例(位于 api 网站内)中效果很好,显示了浏览器中打印的给定纬度和经度 (40.7,-74) 的地点数组。当我尝试在 Foursquare 之外使用它时,会发生以下情况:
我像普通 url 一样使用它,将其粘贴到浏览器中,但不是在浏览器中显示打印的数组,而是显示一个下载窗口,其中包含以下内容:
“您有选择打开 -search-,它是来自 https://api.foursquare.com 的 application/json 类型。浏览器应该做什么,用程序打开它还是保存它?”
弹出。如果我用编辑器打开文件 -search- (或者我保存它并稍后打开它),数组就在那里。
我做错了什么吗?关于为什么我没有在浏览器中获取场地数组的任何线索?
感谢一百万
Foursquare's api has the option to search for venues.
It's an HTTP GET method and has this form:
https://api.foursquare.com/v2/venues/search?ll=40.7,-74&oauth_token=xxxx
In Foursquare's example (which is within the api website) works great, shows the array of venues for the given latitude and longitude (40.7,-74) printed in the browser. When I try to use it out of Foursquare here's what happens:
I'm using it like a normal url, I paste it in a browser but instead of showing an array printed in the browser, a download window with the following:
" You have chosen to open -search- which is an application/json type from https://api.foursquare.com. What should the browser do, open it with a program or save it? "
pops up. If I open the file -search- with an editor (or I save it and I open it later) the array is in there.
What am I doing wrong with this? any clues on why I'm not getting the venues array in the browser?
Thanks a million
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有做错任何事。只是您的计算机没有与
application/json
内容类型关联的程序,因此浏览器要求保存它。因此将其保存为文件,您将看到服务器发送的 JSON 内容。通常,API 应该由程序使用,因此您不应该在浏览器中手动输入此地址 =>您将编写一个使用此 API 的应用程序。
You are not doing anything wrong. It's just that your computer doesn't have an associated program with the
application/json
content type and thus the browser asks to save it. So save it as a file and you will see the contents of the JSON sent by the server.Normally an API is supposed to be consumed by a program, so you should not be manually typing this address in a browser => you will be writing an application consuming this API.
抱歉,我可能没有正确解释自己,我仍在获取 json。适用于我的案例的解决方案:
非常感谢
Sorry, I may not have explained myself correctly, I'm still getting json. The solution that worked in my case:
Thanks a lot