php调用模拟Simsimi(小黄鸡)API_PHP教程
时间:2021-07-01 10:21:17
帮助过:6人阅读
http://developer.simsimi.com/api
SimSimi AICR APIs
1. Conversation API
Conversation API enables you to get SimSimi's response data. Use the Conversation REST API
Request URL:
http://api.simsimi.com/request.p
Request parameters:
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
You can set a filter
Sample request URL:
http://api.simsimi.com/request.p?key=your key&lc=en&ft=1.0&text=hi
Response elements:
Element
Value
Description
result
Integer
100-OK.
400-Bad Request.
401-Unauthorized.
404-Not found.
500-Server Error.
id
Integer
Response id. (you can get only if returning result is 100)
response
String
Response message(you can get only if returning result is 100)
msg
String
Result msg(Description of result code)
Sample response:
{ "result": 100, "response": "Who are you?!", "id": 13185569, "msg": "OK." }
小黄鸡自己公布的API需要email他,然后得到一个key,而且有90天free的限制
以前的代码已经不能用了
Unauthorized access错误!
输出json
//print_r($content);
$json = json_decode($content,true);
if (!empty($json) && $json['result']==100){
echo $json['response'];
}
/*$reply = '你说的话太高深啦,我还听不懂,你可以教教我吗?[兔子]';
$json = json_decode($json, 1);
if (isset($json['response'])) {
$reply = $json['response'];
}
echo $reply;
}*/
}
?>
学习用js, ajax, php做一个简单的小黄鸡页面(调用simsimi API):http://www.verydemo.com/demo_c98_i8695.html
请在输入框中键入消息并回车:
小贱鸡: 大爷,来调戏我啊~~~
http://www.bkjia.com/PHPjc/477669.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/477669.htmlTechArticlehttp://developer.simsimi.com/api SimSimi AICR APIs 1. Conversation API Conversation API enables you to get SimSimis response data. Use the Conversation REST API Request URL: http:/...