Introduction Turing man PHP API

Source: Internet
Author: User
Introduction to Turing man PHP API
Turing 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. So far, the platform has accumulated nearly capacity corpus and PB level of basic data, the overall accuracy of the test platform has reached more than 90%, and the platform has been applied to HTC's small hi voice assistant, China Telecom's platform, Haier's Intelligent home appliance control system, widely praised by enterprises.


Below is a description of his API:


Here is an excerpt from the official website: http://www.tuling123.com/openapi/cloud/api.jsp?section=9


$apiKey = "own Appkey";
$apiURL = "Http://www.tuling123.com/openapi/api?key=KEY&info=INFO";


Set up the message header to build the request message
header ("content-type:text/html; Charset=utf-8 ");
$reqInfo = "Tell a joke";
$url = Str_replace ("INFO", $reqInfo, Str_replace ("KEY", $apiKey, $apiURL));


/** method One, use file_get_contents to get the contents of the content */
$res =file_get_contents ($url);
Echo $res;

/** method Two, using the Curl Library, you need to see if PHP.ini has already opened the Curl extension */
$ch = Curl_init ();
$timeout = 5; curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_connecttimeout, $timeout);
$file _contents = curl_exec ($ch);
Curl_close ($ch);
echo $file _contents;


return Result:


This is a JSON string, so we just use PHP's JSON to process the string.

Returns the returned result using Json_decode () to return the JSON data $data so that the joke can be output through $data->text.


By the same token, we can $reqInfoThis variable allows users to enter their own, you can create their own interface of the robot.





  • 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.