Turing man-java/android

Source: Internet
Author: User

Overview:

Have always felt that this small thing Turing is a very fun thing, today went to the official website to look at, inside a piece of Java code Call sample, and is the main method encapsulated well, I think it can be used directly. No drama at all, in addition to their own import of a few bags, it has been perfectly run.


How to use:

Go to Turing's website: http://www.tuling123.com/openapi/

Register and get Apikey, and you'll be able to use the apikey where you plug in the code, even without adding any additional jar packages. Very convenient.


Java code shows:

public class Testtulingrobot {public static void main (string[] args) throws IOException {String sendinfo = "Nanjing        Bus No. 45 ";        String APIKEY = "Your API Key";                String INFO = Urlencoder.encode (Sendinfo, "utf-8");        System.out.println ("Send info:\n" + sendinfo);        String GetURL = "http://www.tuling123.com/openapi/api?key=" + APIKEY + "&info=" + info;        URL getUrl = new URL (getUrl);        HttpURLConnection connection = (httpurlconnection) geturl.openconnection ();        Connection.connect (); Get the input stream and use reader to read BufferedReader reader = new BufferedReader (New InputStreamReader (Connection.getinputstream (),        "Utf-8"));        StringBuffer sb = new StringBuffer ();                String line = "";        while (line = Reader.readline ())! = null) {sb.append (line);                } reader.close ();        Disconnect Connection.disconnect ();    System.out.println ("Receive info:\n" + SB); }}

The above code does not do any processing of the returned results, because the focus is not on the parsing of JSON, the relevant content can be self-access to the relevant information (of course, I think we are already familiar with the analysis of this data).

The accompanying source contains Java and a relatively complete Android code.

About the source code of Android, is to draw on the code of the cattle, no changes made, in this acknowledgment (this person's many blogs are good, worth learning):

http://blog.csdn.net/lmj623565791/article/details/38498353


Operating Effect:


Fig. 1



Fig. 2



Fig. 3


related source Download:

(Contains simple Java code and relatively complete Android code)

http://download.csdn.net/detail/u013761665/8743461

Turing man-java/android

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.