Issue 1039 in gears: return JSON error(400),Post cell information (CID,LAC,MCC,MNC...) to https://www.googleapis.com/geolocation/v1/geolocate?key=XXXXXXXXXXXXXXXXXX

24 views
Skip to first unread message

ge...@googlecode.com

unread,
Jun 8, 2013, 5:24:45 AM6/8/13
to gear...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 1039 by arima.nj...@gmail.com: return JSON error(400),Post cell
information (CID,LAC,MCC,MNC...) to
https://www.googleapis.com/geolocation/v1/geolocate?key=XXXXXXXXXXXXXXXXXX
http://code.google.com/p/gears/issues/detail?id=1039

Dear all,
I post cell information (CID,LAC,MCC,MNC...) to
https://www.googleapis.com/geolocation/v1/geolocate?key=my_key,but it
always return error 400,can you help me ? Thanks~

1)return error information as follows:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}
2)I implement as follows:
public class SCell{
public int MCC;
public int MNC;
public int LAC;
public int CID;
}
private SItude getItude(SCell cell) throws Exception {
SItude itude = new SItude();

/** Using HttpClient of android by default*/
HttpClient client = new DefaultHttpClient();
/** using post'method */
HttpPost post = new
HttpPost("https://www.googleapis.com/geolocation/v1/geolocate?key=XXXXXXXXXXXXXXXXXX");
try {
/** POST JSON data structure */
JSONObject holder = new JSONObject();
holder.put("homeMobileCountryCode", cell.MCC);
holder.put("homeMobileNetworkCode", cell.MNC);
holder.put("radioType", "gsm");
holder.put("carrier", "cmcc");

JSONObject tower = new JSONObject();
tower.put("cellId", cell.CID);
tower.put("locationAreaCode", cell.LAC);
tower.put("mobileCountryCode", cell.MCC);
tower.put("mobileNetworkCode", cell.MNC);
tower.put("age", 0);
tower.put("signalStrength", -60);
tower.put("timingAdvance", 15);

JSONArray towerarray = new JSONArray();
towerarray.put(tower);
holder.put("cellTowers", towerarray);

StringEntity query = new StringEntity(holder.toString());
post.setEntity(query);

/** send out JSON data,and return data */
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
BufferedReader buffReader = new BufferedReader(new
InputStreamReader(entity.getContent()));
StringBuffer strBuff = new StringBuffer();
String result = null;
while ((result = buffReader.readLine()) != null) {
strBuff.append(result);
}

/** parse JSON data to get longitude and latitude */
JSONObject json = new JSONObject(strBuff.toString());
JSONObject subjosn = new JSONObject(json.getString("location"));

itude.latitude = subjosn.getString("latitude");
itude.longitude = subjosn.getString("longitude");

Log.i("Itude", itude.latitude + itude.longitude);

} catch (Exception e) {
Log.e(e.getMessage(), e.toString());
throw new Exception("error info :"+e.getMessage());
} finally{
post.abort();
client = null;
}

return itude;
}

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

ge...@googlecode.com

unread,
Jun 12, 2013, 3:20:17 AM6/12/13
to gear...@googlegroups.com

Comment #1 on issue 1039 by stevebl...@google.com: return JSON
The Google Gears API is no longer available -
http://gearsblog.blogspot.com.au/2010/02/hello-html5.html
Reply all
Reply to author
Forward
0 new messages