小黄鸡 php,小黄鸡simsimi接口
1.[代碼][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 '我還不會回答這個問題...';
}
}
?>
本文原創發布php中文網,轉載請注明出處,感謝您的尊重!
總結
以上是生活随笔為你收集整理的小黄鸡 php,小黄鸡simsimi接口的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: mindray心电监护仪使用说明_迈瑞心
 - 下一篇: 力科示波器重装系统教程 LECROY示波