Skip to content

Instantly share code, notes, and snippets.

@skorotkiewicz
Created December 8, 2016 15:22
Show Gist options
  • Save skorotkiewicz/2f6a2a493c78d192cd89038b7356a511 to your computer and use it in GitHub Desktop.
Save skorotkiewicz/2f6a2a493c78d192cd89038b7356a511 to your computer and use it in GitHub Desktop.
SimSimi - php talking bot
<?PHP
function simsimi($tresc) {
$curl = curl_init(); if (!$curl) exit;
$headers = array(
'Accept: application/json, text/javascript, */*; q=0.01',
'Content-type: application/json; charset=utf-8',
'Referer: http://www.simsimi.com/talk.htm',
'User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; pl; rv:1.9.2.13) Gecko/20101203 Firefox/3.5.13',
'Cookie: sagree=true; JSESSIONID=9EC7D24A64808F532B1287FFDDCDEC44',
'X-Requested-With: XMLHttpRequest'
);
curl_setopt($curl, CURLOPT_URL, 'http://www.simsimi.com/func/req?msg='.urlencode($tresc).'&lc=en');
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
preg_match_all('#{"response":"(.*)","id":(.*),"result":(.*),"msg":"(.*)"}#sU',
trim($result), $ciag1);
return $ciag1[1][0];
}
echo simsimi('how are you?'); // result: "Great although i wish it would snow :/"
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment