Goolge映射Api通过代码与浏览器返回不同的结果

时间:2018-03-21 12:16:09

标签: java google-maps

调用相同的URL会返回不同的位置坐标: enter image description here

网址:https://maps.googleapis.com/maps/api/place/textsearch/json?key=apicode&query=1412%20norway

代码:

public static void Main(string[] args)
{

    var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://maps.googleapis.com/maps/api/place/textsearch/json?key=apicode&query=1412%20norway");
    httpWebRequest.ContentType = "application/json";
    httpWebRequest.Method = "GET";

    //using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
    //{
    //    string json = "{\"longUrl\":\"http://www.google.com/\"}";
    //    System.Console.WriteLine(json);
    //    streamWriter.Write(json);
    //}

    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
    {
        var responseText = streamReader.ReadToEnd();
        System.Console.WriteLine(responseText);
    }
}

谢谢

更新

fiddler中两个请求的比较。为什么我得到不同的结果? enter image description here

0 个答案:

没有答案