Hi all,
really need an example how to translate a text with this API.
I have implemented already the following:
String googleUrl="https://www.googleapis.com/language/translate/v2?key=<My Key>";
googleUrl+="&q=";
googleUrl+=urlEncode(txtFeedback.getString());
googleUrl+="&source=";
googleUrl+=System.getProperty("microedition.locale ").substring(0, 2);
googleUrl+="&target=en";
HttpConnection googlAPI = null;
DataInputStream dis = null;
StringBuffer response = new StringBuffer();
googlAPI = (HttpConnection)Connector.open(googleUrl);
googlAPI.setRequestMethod(HttpConnection.GET);
dis = new DataInputStream(googlAPI.openInputStream());
int ch;
while ((ch = dis.read()) != -1) {
response.append((char) ch);
}
String tt = response.toString();
tt = tt.substring(tt.indexOf("{"));
JSONObject js = new JSONObject(tt);
params +=js.getJSONObject("data").getJSONArray("translati ons").getJSONObject(0).getString("translatedText" ) + crlf;
but this code throws the Certificate exception: certificate was issued by an unrecognized entity
it throws the exception on my real device Samsung GT-S5230 as well as Emulator
Really need help.
Thank you all.