图灵api接口(图灵开放平台)

网友投稿 403 2023-02-04

本篇文章给大家谈谈图灵api接口,以及图灵开放平台对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。 今天给各位分享图灵api接口的知识,其中也会对图灵开放平台进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

有哪些API接口可以用来做聊天机器人?

1.海知智能:

1. 海知智能第三方技能插件开放平台概述 · ruyi.ai开发者文档 · 看云docs.ruyi.ai

不光能聊天,还可以在网站里内置技能,实现(翻译,成语接龙等)数十项功能
2.天行机器人:

白嫖用户绑定微信后有40000次永久额度,之后1元10000次
3.思知机器人:

AI机器人开放平台 - 思知(OwnThink)www.ownthink.com

4.青云客智能机器人:

青云客智能聊天机器人APIapi.qingyunke.com

5.图灵机器人:

图灵机器人-智能好用的聊天机器人www.turingapi.com

图灵的官网如果不充值好像每日请求次数很低很低,但好在可以通过其他api网站进行调取

6.小i机器人:

模版展示页面nlp.xiaoi.com

但小i机器人没有api使用文档,想要使用就只能自己分析
import urllib.request
import re
message = “”
msg = urllib.parse.quote(message)
link=urllib.request.urlopen("http://nlp.xiaoi.com/robot/webrobotcallback=__webrobot_processMsgdata=%7B%22sessionId%22%3A%22ff725c236e5245a3ac825b2dd88a7501%22%2C%22robotId%22%3A%22webbot%22%2C%22userId%22%3A%227cd29df3450745fbbdcf1a462e6c58e6%22%2C%22body%22%3A%7B%22content%22%3A%22"+msg+"%22%7D%2C%22type%22%3A%22txt%22%7D")
html_doc = link.read().decode()
reply = re.findall(r'\"content\":\"(.+?)\\r\\n\"', html_doc)
print(reply)
可以通过这段python代码进行输入并取得输出

图灵设置API在哪儿

创建方法1.注册图灵机器人账号【/openapi/cloud/api.jsp?section=10】2.下载图灵qq机器人套件,解压机器人到你的电脑上3.点击运行CoolQ.exe4.在弹出框界面,点击基本设置,输入你的图灵机器人apikey,群聊的聊天前缀请进行自定义设定。【注:默认的前缀为@,无聊是私聊还是群聊天,需要加上@,例如“@你好”,机器人才会回复】

求大神问一下,就是我做了一个图灵机器人怎么接入到QQ,就是邀进群里,跪求,谢谢

首先说一下采纳的最佳答案感觉什么也没说。

现在到手的有一个已经申请好的图灵机器人,与其不如说有一个可以对接到QQ的机器人的API。

方法有两种:

第一种比较简单,直接利用酷Q(图灵版)的软件 用QQ登录然后在设置中将申请好的图灵机器人API填入,这个插件就直接可以当做机器人来用了,具体步骤一搜一大堆网页链接。

第二种需要特殊处理,利用Python开发的QQBOT模块可以做到,比较复杂,得安装软件、模块等等一堆的东西,但是实现了会变得很简单。可以参考网页链接,用的是图灵API的低一层新接口(得新申请)。

非专业的话强烈建议用第一种,聊天频率别太快,容易被冻结QQ。

如何用java开发微信

说明:
本次的教程主要是对微信公众平台开发者模式的讲解,网络上很多类似文章,但很多都让初学微信开发的人一头雾水,所以总结自己的微信开发经验,将微信开发的整个过程系统的列出,并对主要代码进行讲解分析,让初学者尽快上手。
在阅读本文之前,应对微信公众平台的官方开发文档有所了解,知道接收和发送的都是xml格式的数据。另外,在做内容回复时用到了图灵机器人的api接口,这是一个自然语言解析的开放平台,可以帮我们解决整个微信开发过程中最困难的问题,此处不多讲,下面会有其详细的调用方式。

1.1 在登录微信官方平台之后,开启开发者模式,此时需要我们填写url和token,所谓url就是我们自己服务器的接口,用WechatServlet.java来实现,相关解释已经在注释中说明,代码如下:

[java] view plain copy

package demo.servlet;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import demo.process.WechatProcess;

/**

* 微信服务端收发消息接口

*

* @author pamchen-1

*

*/

public class WechatServlet extends HttpServlet {

/**

* The doGet method of the servlet. <br

*

* This method is called when a form has its tag value method equals to get.

*

* @param request

*            the request send by the client to the server

* @param response

*            the response send by the server to the client

* @throws ServletException

*             if an error occurred

* @throws IOException

*             if an error occurred

*/

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

request.setCharacterEncoding("UTF-8");

response.setCharacterEncoding("UTF-8");

/** 读取接收到的xml消息 */

StringBuffer sb = new StringBuffer();

InputStream is = request.getInputStream();

InputStreamReader isr = new InputStreamReader(is, "UTF-8");

BufferedReader br = new BufferedReader(isr);

String s = "";

while ((s = br.readLine()) != null) {

sb.append(s);

}

String xml = sb.toString(); //次即为接收到微信端发送过来的xml数据

String result = "";

/** 判断是否是微信接入激活验证,只有首次接入验证时才会收到echostr参数,此时需要把它直接返回 */

String echostr = request.getParameter("echostr");

if (echostr != null  echostr.length()  1) {

result = echostr;

} else {

//正常的微信处理流程

result = new WechatProcess().processWechatMag(xml);

}

try {

OutputStream os = response.getOutputStream();

os.write(result.getBytes("UTF-8"));

os.flush();

os.close();

} catch (Exception e) {

e.printStackTrace();

}

}

/**

* The doPost method of the servlet. <br

*

* This method is called when a form has its tag value method equals to

* post.

*

* @param request

*            the request send by the client to the server

* @param response

*            the response send by the server to the client

* @throws ServletException

*             if an error occurred

* @throws IOException

*             if an error occurred

*/

public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

doGet(request, response);

}

}

1.2 相应的web.xml配置信息如下,在生成WechatServlet.java的同时,可自动生成web.xml中的配置。前面所提到的url处可以填写例如:http;//服务器地址/项目名/wechat.do

[html] view plain copy

<?xml version="1.0" encoding="UTF-8"?

<web-app version="2.5"

xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

<servlet

<descriptionThis is the description of my J2EE component</description

<display-nameThis is the display name of my J2EE component</display-name

<servlet-nameWechatServlet</servlet-name

<servlet-classdemo.servlet.WechatServlet</servlet-class

</servlet

<servlet-mapping

<servlet-nameWechatServlet</servlet-name

<url-pattern/wechat.do</url-pattern

</servlet-mapping

<welcome-file-list

<welcome-fileindex.jsp</welcome-file

</welcome-file-list

</web-app

1.3 通过以上代码,我们已经实现了微信公众平台开发的框架,即开通开发者模式并成功接入、接收消息和发送消息这三个步骤。


下面就讲解其核心部分——解析接收到的xml数据,并以文本类消息为例,通过图灵机器人api接口实现智能回复。
2.1 首先看一下整体流程处理代码,包括:xml数据处理、调用图灵api、封装返回的xml数据。

[java] view plain copy

package demo.process;

import java.util.Date;

import demo.entity.ReceiveXmlEntity;

/**

* 微信xml消息处理流程逻辑类

* @author pamchen-1

*

*/

public class WechatProcess {

/**

* 解析处理xml、获取智能回复结果(通过图灵机器人api接口)

* @param xml 接收到的微信数据

* @return  最终的解析结果(xml格式数据)

*/

public String processWechatMag(String xml){

/** 解析xml数据 */

ReceiveXmlEntity xmlEntity = new ReceiveXmlProcess().getMsgEntity(xml);

/** 以文本消息为例,调用图灵机器人api接口,获取回复内容 */

String result = "";

if("text".endsWith(xmlEntity.getMsgType())){

result = new TulingApiProcess().getTulingResult(xmlEntity.getContent());

}

/** 此时,如果用户输入的是“你好”,在经过上面的过程之后,result为“你也好”类似的内容

*  因为最终回复给微信的也是xml格式的数据,所有需要将其封装为文本类型返回消息

* */

result = new FormatXmlProcess().formatXmlAnswer(xmlEntity.getFromUserName(), xmlEntity.getToUserName(), result);

return result;

}

}

2.2 解析接收到的xml数据,此处有两个类,ReceiveXmlEntity.java和ReceiveXmlProcess.java,通过反射的机制动态调用实体类中的set方法,可以避免很多重复的判断,提高代码效率,代码如下:

[java] view plain copy

package demo.entity;

/**

* 接收到的微信xml实体类

* @author pamchen-1

*

*/

public class ReceiveXmlEntity {

private String ToUserName="";

private String FromUserName="";

private String CreateTime="";

private String MsgType="";

private String MsgId="";

private String Event="";

private String EventKey="";

private String Ticket="";

private String Latitude="";

private String Longitude="";

private String Precision="";

private String PicUrl="";

private String MediaId="";

private String Title="";

private String Description="";

private String Url="";

private String Location_X="";

private String Location_Y="";

private String Scale="";

private String Label="";

private String Content="";

private String Format="";

private String Recognition="";

public String getRecognition() {

return Recognition;

}

public void setRecognition(String recognition) {

Recognition = recognition;

}

public String getFormat() {

return Format;

}

public void setFormat(String format) {

Format = format;

}

public String getContent() {

return Content;

}

public void setContent(String content) {

Content = content;

}

public String getLocation_X() {

return Location_X;

}

public void setLocation_X(String locationX) {

Location_X = locationX;

}

public String getLocation_Y() {

return Location_Y;

}

public void setLocation_Y(String locationY) {

Location_Y = locationY;

}

public String getScale() {

return Scale;

}

public void setScale(String scale) {

Scale = scale;

}

public String getLabel() {

return Label;

}

public void setLabel(String label) {

Label = label;

}

public String getTitle() {

return Title;

}

public void setTitle(String title) {

Title = title;

}

public String getDescription() {

return Description;

}

public void setDescription(String description) {

Description = description;

}

public String getUrl() {

return Url;

}

public void setUrl(String url) {

Url = url;

}

public String getPicUrl() {

return PicUrl;

}

public void setPicUrl(String picUrl) {

PicUrl = picUrl;

}

public String getMediaId() {

return MediaId;

}

public void setMediaId(String mediaId) {

MediaId = mediaId;

}

public String getEventKey() {

return EventKey;

}

public void setEventKey(String eventKey) {

EventKey = eventKey;

}

public String getTicket() {

return Ticket;

}

public void setTicket(String ticket) {

Ticket = ticket;

}

public String getLatitude() {

return Latitude;

}

public void setLatitude(String latitude) {

Latitude = latitude;

}

public String getLongitude() {

return Longitude;

}

public void setLongitude(String longitude) {

Longitude = longitude;

}

public String getPrecision() {

return Precision;

}

public void setPrecision(String precision) {

Precision = precision;

}

public String getEvent() {

return Event;

}

public void setEvent(String event) {

Event = event;

}

public String getMsgId() {

return MsgId;

}

public void setMsgId(String msgId) {

MsgId = msgId;

}

public String getToUserName() {

return ToUserName;

}

public void setToUserName(String toUserName) {

关于图灵api接口和图灵开放平台的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。 图灵api接口的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于图灵开放平台、图灵api接口的信息别忘了在本站进行查找喔。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:idea替换快捷键,批量处理对象的操作
下一篇:详解SpringBoot读取resource目录下properties文件的常见方式
相关文章

 发表评论

暂时没有评论,来抢沙发吧~