Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Google translate api

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Google translate api

    Hi all,

    How can I call the google translate api v2 from my j2me midlet?

    Thank you.


  2. #2
    Junior Member
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Google translate 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.

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Google translate api

    this is a duplicate, so want admin/moderator to delete this one.

Similar Threads

  1. [SOLVED] Google translate API
    By vozmen in forum Java ME (Mobile Edition)
    Replies: 8
    Last Post: December 14th, 2011, 07:06 AM
  2. Translate Turbo Pascal code in Java
    By Mercenaire in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 4th, 2011, 04:52 AM
  3. google search
    By nasi in forum Java Theory & Questions
    Replies: 7
    Last Post: April 2nd, 2010, 03:13 AM
  4. Help to translate from C to java
    By ighor10 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 27th, 2010, 07:36 AM
  5. Translate Java Code Into English
    By drkossa in forum Java Theory & Questions
    Replies: 4
    Last Post: November 27th, 2009, 02:52 PM

Tags for this Thread