调试谷歌地图API查询错误 [英] debugging a google maps api query error

查看:78
本文介绍了调试谷歌地图API查询错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对Google Maps API进行简单的地理编码查询。我似乎没有理由得到一条拒绝错误的消息。我看到大量的帖子提出了相同的问题,但我似乎在做那些没有的东西,并且仍然出现错误。

在最后加上传感器参数会导致拒绝信息,而传感器参数作为第一个信息会给我零结果。我显然在做一些愚蠢的事情。有人可以检查吗?



我粘贴了多次尝试和结果 -


    .googleapis.com / maps / api / geocode / json

    {
    error_message:指定'sensor'参数在请求中必须设置为'true'或'false'。,
    results:[],
    status:REQUEST_DENIED
    }


  1. 使用开发人员页面中指定的示例,将传感器参数作为第一个参数和XML。

    curl http://maps.googleapis.com/maps/api/geocode/xml?sensor=\"false\"&address=\"1600+Amphitheatre+Parkway,+Mountain+View,+CA\"



    $<?xml version =1.0encoding =UTF-8?>
    < GeocodeResponse>
    < status> ZERO_RESULTS< / status>
    < / GeocodeResponse>


  2. 使用开发者页面中指定的示例,并将传感器参数作为最后一个参数。 > curl http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
    $ b

    $ {
    error_message:请求中指定的'sensor'参数必须设置为'true'或'false'。,
    results:[],
    status:REQUEST_DENIED
    }


  3. b

    curl http://maps.googleapis.com/maps/api/geocode/json?address=22222& sensor = false



    $ {
    error_message:请求中指定的'sensor'参数必须设置为'true'或'false'。,
    results:[],
    status:REQUEST_DENIED
    }

  4. 另外一个



    curl http://maps.googleapis.com/maps/api/geocode/json?sensor = false& address =22222



    $ {
    results:[],
    status :ZERO_RESULTS
    }



解决方案

整个网址如下所示:

  curlhttp://maps.googleapis.com/maps/api/geocode/json ?address = 22222& sensor = false


I am trying to do a simple geocoding query to the google maps api. I am getting a message denied error for seemingly no reason. I see a ton of posts with the same question but I seem to be doing what those weren't and still get the error.

Also adding the sensor parameter at the end results in a denied message whereas having the sensor param as the first gives me zero results. I am obviously doing something stupid. Can someone check please?

I am pasting multiple attempts I did and the results -

  1. A HTTP POST attempt -

    curl --data "sensor=false&address=22222" http://maps.googleapis.com/maps/api/geocode/json

    { "error_message" : "The 'sensor' parameter specified in the request must be set to either 'true' or 'false'.", "results" : [], "status" : "REQUEST_DENIED" }

  2. Using the example specified in the developer page with sensor param as the first one and XML.

    curl http://maps.googleapis.com/maps/api/geocode/xml?sensor="false"&address="1600+Amphitheatre+Parkway,+Mountain+View,+CA"

    $ <?xml version="1.0" encoding="UTF-8"?> <GeocodeResponse> <status>ZERO_RESULTS</status> </GeocodeResponse>

  3. Using the example specified in the developer page with sensor param as the last one.

    curl http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

    $ { "error_message" : "The 'sensor' parameter specified in the request must be set to either 'true' or 'false'.", "results" : [], "status" : "REQUEST_DENIED" }

  4. Another attempt

    curl http://maps.googleapis.com/maps/api/geocode/json?address="22222"&sensor=false

    $ { "error_message" : "The 'sensor' parameter specified in the request must be set to either 'true' or 'false'.", "results" : [], "status" : "REQUEST_DENIED" }

  5. Yet another one.

    curl http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address="22222"

    $ { "results" : [], "status" : "ZERO_RESULTS" }

解决方案

Try double quotes for the whole URL, like this:

curl "http://maps.googleapis.com/maps/api/geocode/json?address=22222&sensor=false"

这篇关于调试谷歌地图API查询错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆