科技知识动态:小黄鸡simsimi接口

导读跟大家讲解下有关小黄鸡simsimi接口,相信小伙伴们对这个话题应该也很关注吧,现在就为小伙伴们说说小黄鸡simsimi接口,小编也收集到了有关

跟大家讲解下有关小黄鸡simsimi接口,相信小伙伴们对这个话题应该也很关注吧,现在就为小伙伴们说说小黄鸡simsimi接口,小编也收集到了有关小黄鸡simsimi接口的相关资料,希望大家看到了会喜欢。

1. [代码][PHP]代码

<?phpfunction 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 '我还不会回答这个问题...';}}?>

来源:php中文网

免责声明:本文由用户上传,如有侵权请联系删除!