No SDK is required to call the Turing Robot method!!!

The call of the Turing robot is actually when you send a text message to the server, and he returns you one, which looks like a human conversation.

I don’t know why it is so troublesome to get an SDK. The previous interface official website is no longer available, but it can still be used. The returned JSON is JSON but I am too lazy to parse it. Anyway, the format is fixed, just treat it as a string, simple!

String data = null;
                            try {
                                //Be sure to turn it into utf-8
                                data=URLEncoder.encode(edit.getText().toString(), "utf-8");
                            } catch (UnsupportedEncodingException e) {
                            String strUrl = ""+data;
//The key is your own registration, of course you can use mine directly
                            URL url = null;
                            try {
                                url = new URL(strUrl);
                                HttpURLConnection conn = null;
                                conn = (HttpURLConnection)url.openConnection();
                                conn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
                                //Open the input stream of this page, the content of this website is returned in the form of byte stream. If it is a web page, it will return html, and the picture will return the content of the picture.
                                InputStream inStream = conn.getInputStream();
                                byte [] buf = new byte[1024];
                                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                                int n = 0;
//Use ByteArrayOutputStream to buffer it and convert it to String again, otherwise there will be garbled problems in the space
                                String result = outStream.toString();
//The returned JSON, after making it into a string, remove the head and tail
                                result = result.substring(23,result.length()-2);

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top