Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате |
Форум программистов > Java ME (J2ME) > Google Translate API |
Автор: vozmen 13.12.2011, 22:38 |
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("translations").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. |
Автор: vozmen 13.12.2011, 23:42 |
If I do something wrong it would be great to get an example how to call the google translate API from j2me midlet. Thank you. |
Автор: vozmen 14.12.2011, 00:09 |
Возможно я что-то не так делаю... тогда вопрос - как правильно "дергать" google translate api v2 из j2me midlet? спасибо. |
Автор: vozmen 14.12.2011, 12:59 |
Похоже что работает на Nokia но не работает на Samsung |
Автор: oxigen 14.12.2011, 16:22 |
Вы пытаетесь с помощью HttpConnection открыть https Попробуйте использовать HttpsConnection |
Автор: vozmen 31.5.2012, 21:40 |
Это не помогло. Еще предложения. Спасибо. |