Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json google将api放置在无效的\u请求中_Json_Google Places Api - Fatal编程技术网

Json google将api放置在无效的\u请求中

Json google将api放置在无效的\u请求中,json,google-places-api,Json,Google Places Api,在这个请求url中,我需要知道“引用”包含什么。实际上,这就是需要传递给api的搜索文本。但我在发送到api调用之前使用了字符串编码,如下所示 https://maps.googleapis.com/maps/api/place/details/json?reference=CmRYAAAAciqGsTRX1mXRvuXSH2ErwW-jCINE1aLiwP64MCWDN5vkXvXoQGPKldMfmdGyqWSpm7BEYCgDm-iv7Kc2PF7QA7brMAwBbAcqMr5i1f4P

在这个请求url中,我需要知道“引用”包含什么。实际上,这就是需要传递给api的搜索文本。但我在发送到api调用之前使用了字符串编码,如下所示

https://maps.googleapis.com/maps/api/place/details/json?reference=CmRYAAAAciqGsTRX1mXRvuXSH2ErwW-jCINE1aLiwP64MCWDN5vkXvXoQGPKldMfmdGyqWSpm7BEYCgDm-iv7Kc2PF7QA7brMAwBbAcqMr5i1f4PwTpaovIZjysCEZTry8Ez30wpEhCNCXpynextCld2EBsDkRKsGhSLayuRyFsex6JA6NPh9dyupoTH3g&key=AddYourOwnKeyHere
但它仍然以普通编码字符串(如“London”)的形式发送查询


如何实现GoogleAPI请求中给出的类似编码的引用。有人能帮我吗…

使用下面的链接。这里有一些例子。也许它会帮助你


在自动完成搜索中搜索地点时,我们应该发送请求以获取地点详细信息url。您的结构应与此类似:

private String getPlacesUrl(String query) {

    try {
        query = "input=" + URLEncoder.encode(query, "utf-8");
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }
return query;
   }
有关更多详细信息,请参考此网站作为基础。非常好。

private String getPlaceDetailsUrl(String ref){

    // reference of place
    String reference = "reference="+ref;

    // Sensor enabled
    String sensor = "sensor=false";

    // Building the parameters to the web service
    String parameters = reference+"&"+sensor+"&"+mKey;

    // Output format
    String output = "json";

    // Building the url to the web service
    String url = "https://maps.googleapis.com/maps/api/place/details/"+output+"?"+parameters;

    return url;
}