使用 HTTParty 将 json 发布到 Google 地方信息
我试图弄清楚如何使用 HTTParty 编写 google place POST 请求。我能够执行 GET 请求,但不知道如何解决 Google 地方信息有一个要发布的嵌套参数这一事实。这是 api 文档中的 json 语法。有人可以帮我将其翻译成可以与 HTTParty.post 一起使用的语法吗
POST https://maps.googleapis.com/maps/api/place/add/json?sensor=true_or_false&key=api_key HTTP/1.1
Host: maps.googleapis.com
{
"location": {
"lat": -33.8669710,
"lng": 151.1958750
},
"accuracy": 50,
"name": "Google Shoes!",
"types": ["shoe_store"],
"language": "en-AU"
}
I'm trying to figure out how to write a google places POST request using HTTParty. I was able to do a GET request but can't figure out how to work around the fact that Google Places has a nested parameter to post into. Here is the json syntax from the api documentation. Can someone help me translate this into the syntax that can work with HTTParty.post
POST https://maps.googleapis.com/maps/api/place/add/json?sensor=true_or_false&key=api_key HTTP/1.1
Host: maps.googleapis.com
{
"location": {
"lat": -33.8669710,
"lng": 151.1958750
},
"accuracy": 50,
"name": "Google Shoes!",
"types": ["shoe_store"],
"language": "en-AU"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
httparty gem 包括 将嵌套 JSON 发布到服务器的示例。
The httparty gem includes an example that posts nested JSON to a server.