Google翻訳API v2でテキストを翻訳する方法の例が本当に必要です.
私はすでに以下を実装しています:
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;
しかし、このコードは証明書の例外をスローします: 証明書は認識されていないエンティティによって発行されました
私の実際のデバイスSamsung GT-S5230とエミュレーターで例外をスローします
本当に助けが必要です。
私が何か間違ったことをした場合、j2me midlet から Google 翻訳 API を呼び出す方法の例を得ることができれば幸いです。