私はJava Scriptで次のコードを持っています:
var requestData =
{
"homeMobileCountryCode": 732,
"homeMobileNetworkCode": 123,
"radioType": "gsm",
"carrier": "Vodafone",
"cellTowers":
[
{
"cellId": 21282,
"locationAreaCode": 2110,
"mobileCountryCode": 732,
"mobileNetworkCode": 123,
"age": 0,
"signalStrength": (57 - 110)
}
]
}
var encoded = $.toJSON(requestData);
$.ajax({
url: "https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyA8UJK3m8_X_6GV3T5EWHc86GIuMhITu34",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: encoded,
success: function (response) {
var location = response.location;
var lat = location.latitude;
var lon = location.longitude;
var address = location.address.street_number + " " + location.address.street + " " + location.address.city + " " + location.address.county + " " + location.address.country;
},
error: function (er) {
alert("error " + er.message + " codigo: " + er.code);
}
});
リクエストは私に何も返さず、警告エラー: apears object undefined であるため、JSON を使用して Google にこのサービスを呼び出す例を教えてください。私はASP.Netに取り組んでいます
こんにちは、この種のリクエストを行った経験がありません。次のコードがあります。
Tower tower = new Tower();
tower.MobileCountryCode = "310";
tower.MobileNetworkCode = "260";
tower.CellsTowers = new List<CellTower>();
tower.CellsTowers.Add(new CellTower()
{
CellId = "39627456",
LocationAreaCode = "40495",
MobileCountryCode = "310",
MobileNetworkCode = "260",
SignalStrength = "-95",
Age = "0"
});
string jsonFormat = ToJSON(tower);
WebRequest request = WebRequest.Create("https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyA8UJK3m8_X_6GV3T5EWHc86GIuMhITu34" + jsonFormat);
そして、私はフォロー機能を持っています:
string ToJSON(object obj)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(obj);
}
しかし、サービスの応答: エラー 400、無効な要求 ...
何か案が ??