search
Homephp教程php手册介绍图灵机器人php API

图灵机器人平台,基于自然语言处理、知识库和云计算等技术,为广大开发者、合作伙伴提供的一系列智能语义处理能力(包括语义理解、智能问答、知识库对接等)的服务平台。截止到目前为止,平台已经积累了近百亿条语料库和PB级别的基础数据,经测试平台的整体准确度已经达到90%以上,而且平台已经应用于HTC的小Hi语音助手、中国电信的微信平台、海尔的智能家电控制系统等,广受企业的好评。
下面介绍下他的api:
下面这里摘自官网:http://www.tuling123.com/openapi/cloud/api.jsp?section=9
$apiKey = "自己的appKey";
$apiURL = "http://www.tuling123.com/openapi/api?key=KEY&info=INFO";
// 设置报文头, 构建请求报文
header("Content-type: text/html; charset=utf-8");
$reqInfo = "讲个笑话";
$url = str_replace("INFO", $reqInfo, str_replace("KEY", $apiKey, $apiURL));

/** 方法一、用file_get_contents 以get方式获取内容 */
$res =file_get_contents($url);
echo $res;

/** 方法二、使用curl库,需要查看php.ini是否已经打开了curl扩展 */
$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;
返回结果:
这是一个json 字符串,我们只要使用php的json处理字符串就行

将返回结果使用 json_decode() 返回json 数据$data,这样可以通过$data->text 来输出笑话。
同理,我们可以通过$reqInfo 这个变量让用户自己输入,就可以制作属于自己的界面的机器人了。





Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools