1、什麼是Simsimi?java
simsimi公司是提供智能服務,其中一個服務是simsimi聊天機器人服務,天天有超過百萬的用戶聊天,國內最大的搜索引擎——百度的產品siri使用的就是simsimi提供的api。web
你能夠在網址http://www.simsimi.com/talk.htm# 進行體驗apache
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.api
We invite you to our realm of service which is available through our cloud of collective intelligence, Crowd Cloud that SimSimi inc. creates.瀏覽器
2、Simsimi小黃雞API微信
在 去年的這個時候,小黃雞的非官方api一度被你們瘋狂的在微信公衆號上使用,一時間不知道成就了多少微信營銷號,同時,華科某位大四學生利用這個api, 結合人人網開發平臺,製做了一個小黃雞的人人號,@小黃雞以後,就能夠利用api自動進行回覆,是的這我的人號瞬間粉絲陡增。dom
然而你們使用的都是非官方的API,所謂非官方,就是否是simsimi公司提供的合法使用途徑,API大體的原理是利用編程語言,模擬瀏覽器發送post請求到http://www.simsimi.com/talk.htm# 鏈 接,解析響應,而後做成相關的小黃雞API。這個方法後來被我在本博客中在博文中發佈,致使使用人數激增,simsimi公司彷佛察覺了什麼,立馬對這種 模擬請求的方式作出了屏蔽,一旦某ip請求數量和頻率超過限制,則終端對它的請求。正式官方對非法API的封鎖,也使用國內的開發這關注到以前並不出名的 小i機器人,一樣使用語言模擬請求web聊天界面,時間沒有過好久,這個頁面就加入了圖片驗證碼防止程序模擬。編程語言
至此,兩個聊天機器人都走上了收費的道路...準確的說,應該是被這幫子開發者遇上了收費的道路,由於他們給它帶來了知名度。ide
3、SimsimiAPI使用
目前,小黃雞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請求參數爲:
Parameter | Value | Required | Default | Description |
---|---|---|---|---|
key | String | Y | Your key value | |
text | String | Y | Query message | |
lc | String | Y | Language code(List) | |
ft | Double(0.0 ~ 1.0) | 0.0 | 能夠設置一個過濾器 0.0:未過濾(包含詛咒,性內容) 1.0:過濾不文明字句(暫時只支持韓文) 過濾內容,請訪問下面的網站。 https://www.webpurify.com/ |
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對應的含義
4、Simsimi使用舉例
請求舉例:
Trial-key http://sandbox.api.simsimi.com/request.p?key=your_trial_key&lc=en&ft=1.0&text=hi
Paid-key http://api.simsimi.com/request.p?key=your_paid_key&lc=en&ft=1.0&text=hi
響應舉例:
{ "result": 100, "response": "Who are you?!", "id": 13185569, "msg": "OK." }
5、如何免費的使用Simsimi API
我想,你們都懂了,寫這篇文章的緣由就是不少人搜索小黃雞 api到個人博客,我想你們都是要找免費的小黃雞API。這裏提供給你們一個思路:
合做夥伴中,有人人網,爲何?本博文前面提升某大四學生作了一我的人號,@小黃雞以後,會自動進行回覆,他使用的就是simsimi的官方正版付費API,既然人人網提供開發平臺,能夠對賬號進行回覆,得到回覆等等操做,爲何不能使用程序,登陸賬號,而後@小黃雞,而後得到它的回覆,再返回給你本身的用戶呢?答案固然是能夠的!!!
下面貼出一段可供參考的Java代碼,之因此爲僅供參考,就是說只能參考思路,代碼運行是運行不起來的!!!
若是可以幫助到你,但願回覆點評一下,你懂的...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
import
java.o.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
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;
}
}
|