Share The chat robot interface of simsimi in php. Copy the code as follows :? Phpfunctionsimsimi ($ keyword) {$ keywordurlencode (urlencode ($ keyword); ----------- get COOKIE -------- $ urlwww.simsimi.com; $ c
The code is as follows:
Function simsimi ($ keyword ){
$ Keyword = urlencode ($ keyword ));
// ----------- Get 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", $ content );
Preg_match ("/set \-cookie :( [^ \ r \ n] *);/iU", $ header, $ matches );
$ Cookie = $ matches [1];
Curl_close ($ ch );
// ----------- Capture and restore ----------//
$ 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'] = '000000 '){
$ Content ['response'];
Return $ content ['response'];
} Else {
Return 'I will not answer this question ...';
}
}
?>
The http://www.bkjia.com/PHPjc/728117.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/728117.htmlTechArticle code is as follows :? Php function simsimi ($ keyword) {$ keyword = urlencode ($ keyword); // ----------- get COOKIE ---------- // $ url = "http://www.simsimi.com /"; $ c...