小黄鸡SimSimi API以及小i机器人的说明——如何免费使用?

一、什么是Simsimi?

simsimi公司是提供智能服务,其中一个服务是simsimi聊天机器人服务,每天有超过百万的用户聊天,国内最大的搜索引擎——百度的产品siri使用的就是simsimi提供的api。

你可以在网址http://www.simsimi.com/talk.htm# 进行体验

SimSimi inc. is specialized in collective intelligence service. All kinds of services we provide generates unique entertainment and values through systemized collective intelligence.

One of our services, a chatting robot SimSimi exceeds the limitation of technology of natural-language processing system by collective intelligence and it has a chat with over millions user per day. Our Premium knowledge providing service “Jisikman” creates millions of valuable knowledges a day.

We invite you to our realm of service which is available through our cloud of collective intelligence, Crowd Cloud that SimSimi inc. creates.

二、Simsimi小黄鸡API

在去年的这个时候,小黄鸡的非官方api一度被大家疯狂的在微信公众号上使用,一时间不知道成就了多少微信营销号,同时,华科某位大四学生利用这个api,结合人人网开发平台,制作了一个小黄鸡的人人号,@小黄鸡之后,就可以利用api自动进行回复,是的这个人人号瞬间粉丝陡增。

然而大家使用的都是非官方的API,所谓非官方,就是不是simsimi公司提供的合法使用途径,API大致的原理是利用编程语言,模拟浏览器发送post请求到http://www.simsimi.com/talk.htm# 链接,解析响应,然后作成相关的小黄鸡API。这个方法后来被我在本博客中在博文中发布,导致使用人数激增,simsimi公司似乎察觉了什么,立马对这种模拟请求的方式做出了屏蔽,一旦某ip请求数量和频率超过限制,则终端对它的请求。正式官方对非法API的封锁,也使用国内的开发这关注到之前并不出名的小i机器人,同样使用语言模拟请求web聊天界面,时间没有过很久,这个页面就加入了图片验证码防止程序模拟。

至此,两个聊天机器人都走上了收费的道路...准确的说,应该是被这帮子开发者赶上了收费的道路,因为他们给它带来了知名度。

三、SimsimiAPI使用
13845160832840.jpg

目前,小黄鸡API已经公然收费(http://developer.simsimi.com/api
不过,和之前一样,会给注册用户提供30天的试用API。
API请求链接为:
Trial-key    http://sandbox.api.simsimi.com/request.p
Paid-key    http://api.simsimi.com/request.p

API请求参数见官网。
 
API返回格式为:

result:100-ok. 400-Bad Request. 401-Unauthorized. 404-Not found. 500-Server Error.    返回的code

id:Response id. (you can get only if returning result is 100)回复的id,由系统生成,当请求成功返回时才有这个字段。 

response:Response message(you can get only if returning result is 100)返回的回复内容。

msg:Result  msg(Description of result code) 返回的code对应的含义

四、Simsimi使用举例

请求举例:

Trial-key    http://sandbox.api.simsimi.com ... %3Dhi   
Paid-key    http://api.simsimi.com/request ... %3Dhi

响应举例:

{ "result": 100, "response": "Who are you?!", "id": 13185569, "msg": "OK." }

五、如何免费的使用Simsimi API

我想,大家都懂了,写这篇文章的原因就是很多人搜索小黄鸡 api到我的博客,我想大家都是要找免费的小黄鸡API。这里提供给大家一个思路:
 
合作伙伴中,有人人网,为什么?本博文前面提高某大四学生做了一个人人号,@小黄鸡之后,会自动进行回复,他使用的就是simsimi的官方正版付费API,既然人人网提供开发平台,可以对帐号进行回复,获得回复等等操作,为什么不能使用程序,登录帐号,然后@小黄鸡,然后获得它的回复,再返回给你自己的用户呢?答案当然是可以的!!!

下面贴出一段可供参考的Java代码,之所以为仅供参考,就是说只能参考思路,代码运行是运行不起来的!!!如果能够帮助到你,希望回复点评一下,并点点广告,你懂的...
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
/**
* 利用httpclient操作人人网 比如登陆,发状态,模拟你访问任何人主页等等
* @author: http://50vip.com
*
*/
public class RenRen {
private String userName = "";
private String password = "";

private static String redirectURL = "http://www.renren.com/home";
private static String renRenLoginURL = "http://www.renren.com/PLogin.do";
private static String talkUrl = "http://photo.renren.com/photo/ ... 3B%3B
private HttpResponse response;
private DefaultHttpClient httpclient = null;
private String requestToken = null;
private String _rtk = null;

public RenRen(String userName, String password) {
this.userName = userName;
this.password = password;
}

public static void main(String[] args) {
RenRen rr = null;
rr = new RenRen("xxxxx@hotmail.com", "yyyyy");
rr.login();
System.out.println(rr.talk("820"));
}
/**
* 登陆
* @author: http://50vip.com
* @return
*/
public boolean login() {
if (httpclient != null) {
return true;
}
httpclient = null;
httpclient = new DefaultHttpClient();
HttpPost httpost = new HttpPost(renRenLoginURL);
// All the parameters post to the web site
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("origURL", redirectURL));
nvps.add(new BasicNameValuePair("domain", "renren.com"));
nvps.add(new BasicNameValuePair("autoLogin", "true"));
nvps.add(new BasicNameValuePair("formName", ""));
nvps.add(new BasicNameValuePair("method", ""));
nvps.add(new BasicNameValuePair("submit", "登录"));
nvps.add(new BasicNameValuePair("email", userName));
nvps.add(new BasicNameValuePair("password", password));
try {
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
response = httpclient.execute(httpost);
//System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
httpost.abort();
}

String redirectLocation = getRedirectLocation();
if (redirectLocation != null) {
// 跳到首页,登录完成
String indexHtml=getText(redirectLocation);

//获取requestToken get_check:'-2062261917'
Pattern pattern1 = Pattern.compile("get_check:'(.*)',get_check_x");
Matcher m1 = pattern1.matcher(indexHtml);
if (m1.find()) {
requestToken=m1.group(1);
} else {
System.out.println("获取requestToken失败!");
}

//"获取_rtk失败!"get_check_x:'50d55fbd'
Pattern pattern2 = Pattern.compile("get_check_x:'(.*)',env:");
Matcher m2 = pattern2.matcher(indexHtml);
if (m2.find()) {
_rtk=m2.group(1);
} else {
System.out.println("获取_rtk失败!");
}
}
return true;
}

/**
* 和人人的小黄鸡交谈
* @author: http://50vip.com
* @param msg
* @return
*/
public String talk(String msg) {
String repMsg="";//小黄的回复

HttpPost httpost = new HttpPost(talkUrl);
// All the parameters post to the web site
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("_rtk", _rtk));
nvps.add(new BasicNameValuePair("requestToken", requestToken));
nvps.add(new BasicNameValuePair("message", msg));

try {
ResponseHandler<String> responseHandler = new BasicResponseHandler();
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
repMsg=httpclient.execute(httpost, responseHandler);
} catch (Exception e) {
e.printStackTrace();
} finally {
httpost.abort();
}
return repMsg;
}

/**
* 此处人人网会302跳转
* @author: http://50vip.com
* @return
*/
private String getRedirectLocation() {
Header locationHeader = response.getFirstHeader("Location");
if (locationHeader == null) {
return null;
}
return locationHeader.getValue();
}

/**
* 读取首页内容
* @author: http://50vip.com
* @param redirectLocation
* @return
*/
private String getText(String redirectLocation) {
HttpGet httpget = new HttpGet(redirectLocation);
// Create a response handler
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = "";
try {
responseBody = httpclient.execute(httpget, responseHandler);
} catch (Exception e) {
e.printStackTrace();
responseBody = null;
} finally {
httpget.abort();
}
return responseBody;
}
}

0 个评论

要回复文章请先登录注册