【问题标题】:trouble adding place through google places api通过 google 地方 api 添加地点时遇到问题
【发布时间】:2011-12-19 16:26:42
【问题描述】:

我正在尝试通过 Coldfusion 使用 google places api 将地点添加到 google 地图,我已在 API 设置中启用地点并使用正确的密钥,因为我能够搜索半径 100 米内的地点。

当我尝试添加地点时,我在 return 语句中得到“INVALID_REQUEST”。

代码如下:

<cfsavecontent variable="variables.addString">
  <?xml version="1.0" encoding="UTF-8"?>
  <PlaceAddRequest>
      <location>
          <lat><cfoutput>#variables.lat#</cfoutput></lat>
          <lng><cfoutput>#variables.lng#</cfoutput></lng>
      </location>
      <accuracy>20</accuracy>
      <name><cfoutput>#variables.placeName#</cfoutput></name>
  </PlaceAddRequest>
</cfsavecontent>

<cfhttp
    url='https://maps.googleapis.com/maps/api/place/add/xml?sensor=false&key=#variables.googlekey#'
    method="POST"
    useragent="#CGI.http_user_agent#"
    result="objGet"
>

<cfhttpparam
    type="XML"
    value="#Trim(variables.addString)#"
/>
</cfhttp>

有人知道这里出了什么问题吗?

【问题讨论】:

  • 无需深入挖掘,我已经可以看到您的响应 (variables.addString) 不符合 XML,因为它不是以 。可能不是问题,但它绝对是一个开始......
  • 感谢 Shawn,我修复了 xml,但问题仍然存在。我已经更新了上面的代码。

标签: xml coldfusion google-places-api


【解决方案1】:

variables.addString.Trim() 是什么?你是说trim(variables.addString)

【讨论】:

  • 是的,这是一个复制粘贴错误。我修复了它,但我仍然收到无效请求。
【解决方案2】:

缺少类型参数。这是一个必需的参数,即使它在reference docs 中没有这样记录。我已经提交了一个错误来修复文档。希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-19
    • 1970-01-01
    • 2011-09-22
    • 2020-05-22
    相关资源
    最近更新 更多