public void sendRequest() throws IOException
    {
        /* Create & Format URL */
        URL url = new URL(CleverBotQuery.formatRequest(CleverBotQuery.URL_STRING, this.key, this.phrase, this.conversationID));

        /* Open Connection */
        URLConnection urlConnection = url.openConnection();

        /* Read input */
        BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
        String inputLine = in.readLine();

        /* Create JSON Object */
        JsonObject jsonObject = new JsonParser().parse(inputLine).getAsJsonObject(); // convert to JSON

        /* Get params */
        this.setConversationID(jsonObject.get("cs").getAsString()); // update conversation ID
        this.setResponse(jsonObject.get("output").getAsString()); // get output
        this.setRandomNumber(Integer.parseInt(jsonObject.get("random_number").getAsString())); // get output
        in.close(); // close!
    }
public void sendRequest ( ) throws IOException { URL url = new URL ( CleverBotQuery . formatRequest ( CleverBotQuery . URL_STRING , this . key , this . phrase , this . conversationID ) ) ; URLConnection urlConnection = url . openConnection ( ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( urlConnection . getInputStream ( ) ) ) ; String inputLine = in . readLine ( ) ; JsonObject jsonObject = new JsonParser ( ) . parse ( inputLine ) . getAsJsonObject ( ) ; this . setConversationID ( jsonObject . get ( "cs" ) . getAsString ( ) ) ; this . setResponse ( jsonObject . get ( "output" ) . getAsString ( ) ) ; this . setRandomNumber ( Integer . parseInt ( jsonObject . get ( "random_number" ) . getAsString ( ) ) ) ; in . close ( ) ; }
Sends request to CleverBot servers. API key and phrase should be set prior to this call

@throws IOException exception upon query failure