Created
December 8, 2016 15:22
-
-
Save skorotkiewicz/2f6a2a493c78d192cd89038b7356a511 to your computer and use it in GitHub Desktop.
SimSimi - php talking bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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