使用Google Maps API我想要获取到不同地方的距离。如果我只将这个地方(没有街道)交付给API,我工作得很好。如果我将街道添加到我的查询中(使用file_get_contents),我收到了400个错误请求。如果我在浏览器中键入查询我得到正确的JSON回报file_get_contents返回400错误请求
这是失败的查询:
file_get_contents(https://maps.googleapis.com/maps/api/distancematrix/json?origins=Laischaftsstr. 38 Osnabrück&destinations=München|Potsdam|Dortmund|Flensburg|Berlin&sensor=false)
这是工作正常查询:
file_get_contents(https://maps.googleapis.com/maps/api/distancematrix/json?origins=Osnabrück&destinations=München|Potsdam|Dortmund|Flensburg|Berlin&sensor=false)