導讀跟大家講解下有關小黃雞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中文網