Turing platform is a free API open platform, based on natural language processing, knowledge base and cloud computing technology, for the vast number of developers, partners to provide a range of intelligent semantic processing capabilities (including semantic understanding, intelligent Quiz, knowledge base docking, etc.) service platform. API use Address:http://www.tuling123.com/openapi/record.do?channel=50044
Today, I made a simple real-time answer program with the Turing's Open API:)
robot.php:
<?phperror_reporting (0); $INFO =$_get[' INFO '];if (! $INFO) $INFO = "hello!"; $apiKey = "AAAAAAAAAAAAAAAAAAAAAAA"; Your appkey$apiurl= "http://www.tuling123.com/openapi/api?key= $apiKey &info= $INFO";//appkey address $cmd=file_get_ Contents ($apiURL);//echo $cmd. " <br> ";//output JSON format information (not in this instance) $tmp =json_decode ($cmd, 1), if ($tmp [code][0]!=" 4 ")//JSON decoding if there is no error (the return code starts with 4), The text message { Print_r ($tmp [text]) is displayed; } else { echo "Error!error code is: $tmp [code]!]; }?>
Demo.html
<form> say:<input type= "text" id= "Robot" onkeyup= "Showhint (this.value)"/> Triggers an event to send an AJAX request when the keyboard strikes </FORM&G T;<p>ans: <span id= "Txthint" ></span></p> as Echo zone <script>var xmlhttpfunction Showhin T (str) {if (str.length==0) {document.getElementById ("Txthint"). innerhtml= ""; Return } xmlhttp=getxmlhttpobject () if (xmlhttp==null) {alert ("Your browser does not support ajax! "); Return } var url= "robot.php"; url=url+ "info=" +STR; url=url+ "&sid=" +math.random (); xmlhttp.onreadystatechange=statechanged; Xmlhttp.open ("GET", url,true); Xmlhttp.send (null);} function statechanged () {if (xmlhttp.readystate==4) {document.getElementById ("Txthint"). innerhtml= Xmlhttp.responsetext;}} function Getxmlhttpobject () {var xmlhttp=null; try {//Firefox, Opera 8.0+, Safari xmlhttp=new XMLHttpRequest (); } catch (E) {///Internet Explorer try {xmlhttp=new ActiveXObject ("msxml2.xmlhttp"); } catch (e) { Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP"); }}return xmlHttp;} </script>
API Practice: Write an auto-answer Web page with the Turing man API