源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

php版小黄鸡simsimi聊天机器人接口分享

  • 时间:2020-12-28 00:43 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:php版小黄鸡simsimi聊天机器人接口分享
[u]复制代码[/u] 代码如下:
<?php function simsimi($keyword) {  $keyword = urlencode(urlencode($keyword));  //----------- 获取COOKIE ----------//  $url = "http://www.simsimi.com/";  $ch = curl_init($url);  curl_setopt($ch, CURLOPT_HEADER,1);  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);  $content = curl_exec($ch);  list($header, $body) = explode("\r\n\r\n", $content);  preg_match("/set\-cookie:([^\r\n]*);/iU", $header, $matches);  $cookie = $matches[1];  curl_close($ch);  //----------- 抓 取 回 复 ----------//  $url = "http://www.simsimi.com/func/req?lc=ch&msg=$keyword&ft=0.0";  $ch = curl_init($url);  curl_setopt($ch, CURLOPT_REFERER, "http://www.simsimi.com/talk.htm?lc=ch");  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);  curl_setopt($ch, CURLOPT_COOKIE, $cookie);  $content = json_decode(curl_exec($ch),1);  curl_close($ch);  if($content['result']=='100') {   $content['response'];   return $content['response'];  } else {   return '我还不会回答这个问题...';  } } ?>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部