Yellow chicken Simsimi is a lovely intelligent chat robot, he can engage in interesting conversations with users, this article mainly introduces the PHP version of the Yellow chicken Simsimi Interface Use example, we refer to the use of the bar
Code as follows: <?php function Simsimi ($keyword) { $keyword = UrlEncode (UrlEncode ($keyword)); //----- ------Get Cookies----------// $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 ("Rnrn", $content); preg_match ("/set-cookie: ([^rn]*);/iu", $header, $matches); $cookie = $matches [1]; curl_close ($ch); //-----------Crawl reply----------// $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 ']== ') { $content [' response ']; return $content [' response ']; &NBSP} else { Return ' I'm not going to answer this question ... ' }?>