public function thinkThought($thought) { $this->vars['stimulus'] = $thought->getText(); $data = http_build_query($this->vars); $dataToDigest = substr($data, 9, $this->bot->getEndIndex()); $dataDigest = md5($dataToDigest); $this->vars['icognocheck'] = $dataDigest; $response = _utils_post($this->bot->getUrl(), $this->vars); $responseValues = explode("\r", $response); //self.vars['??'] = _utils_string_at_index($responseValues, 0); $this->vars['sessionid'] = _utils_string_at_index($responseValues, 1); $this->vars['logurl'] = _utils_string_at_index($responseValues, 2); $this->vars['vText8'] = _utils_string_at_index($responseValues, 3); $this->vars['vText7'] = _utils_string_at_index($responseValues, 4); $this->vars['vText6'] = _utils_string_at_index($responseValues, 5); $this->vars['vText5'] = _utils_string_at_index($responseValues, 6); $this->vars['vText4'] = _utils_string_at_index($responseValues, 7); $this->vars['vText3'] = _utils_string_at_index($responseValues, 8); $this->vars['vText2'] = _utils_string_at_index($responseValues, 9); $this->vars['prevref'] = _utils_string_at_index($responseValues, 10); //$this->vars['??'] = _utils_string_at_index($responseValues, 11); $this->vars['emotionalhistory'] = _utils_string_at_index($responseValues, 12); $this->vars['ttsLocMP3'] = _utils_string_at_index($responseValues, 13); $this->vars['ttsLocTXT'] = _utils_string_at_index($responseValues, 14); $this->vars['ttsLocTXT3'] = _utils_string_at_index($responseValues, 15); $this->vars['ttsText'] = _utils_string_at_index($responseValues, 16); $this->vars['lineRef'] = _utils_string_at_index($responseValues, 17); $this->vars['lineURL'] = _utils_string_at_index($responseValues, 18); $this->vars['linePOST'] = _utils_string_at_index($responseValues, 19); $this->vars['lineChoices'] = _utils_string_at_index($responseValues, 20); $this->vars['lineChoicesAbbrev'] = _utils_string_at_index($responseValues, 21); $this->vars['typingData'] = _utils_string_at_index($responseValues, 22); $this->vars['divert'] = _utils_string_at_index($responseValues, 23); $responseThought = new ChatterBotThought(); $responseThought->setText(_utils_string_at_index($responseValues, 16)); return $responseThought; }
public function thinkThought($thought) { $this->vars['stimulus'] = $thought->getText(); $data = http_build_query($this->vars); $dataToDigest = substr($data, 9, $this->bot->getEndIndex()); $dataDigest = md5($dataToDigest); $this->vars['icognocheck'] = $dataDigest; $response = _utils_request($this->bot->getServiceUrl(), $this->cookies, $this->vars); $responseValues = explode("\r", $response); //self.vars['??'] = _utils_string_at_index($responseValues, 0); $this->vars['sessionid'] = _utils_string_at_index($responseValues, 1); $this->vars['logurl'] = _utils_string_at_index($responseValues, 2); $this->vars['vText8'] = _utils_string_at_index($responseValues, 3); $this->vars['vText7'] = _utils_string_at_index($responseValues, 4); $this->vars['vText6'] = _utils_string_at_index($responseValues, 5); $this->vars['vText5'] = _utils_string_at_index($responseValues, 6); $this->vars['vText4'] = _utils_string_at_index($responseValues, 7); $this->vars['vText3'] = _utils_string_at_index($responseValues, 8); $this->vars['vText2'] = _utils_string_at_index($responseValues, 9); $this->vars['prevref'] = _utils_string_at_index($responseValues, 10); //$this->vars['??'] = _utils_string_at_index($responseValues, 11); $this->vars['emotionalhistory'] = _utils_string_at_index($responseValues, 12); $this->vars['ttsLocMP3'] = _utils_string_at_index($responseValues, 13); $this->vars['ttsLocTXT'] = _utils_string_at_index($responseValues, 14); $this->vars['ttsLocTXT3'] = _utils_string_at_index($responseValues, 15); $this->vars['ttsText'] = _utils_string_at_index($responseValues, 16); $this->vars['lineRef'] = _utils_string_at_index($responseValues, 17); $this->vars['lineURL'] = _utils_string_at_index($responseValues, 18); $this->vars['linePOST'] = _utils_string_at_index($responseValues, 19); $this->vars['lineChoices'] = _utils_string_at_index($responseValues, 20); $this->vars['lineChoicesAbbrev'] = _utils_string_at_index($responseValues, 21); $this->vars['typingData'] = _utils_string_at_index($responseValues, 22); $this->vars['divert'] = _utils_string_at_index($responseValues, 23); $responseThought = new ChatterBotThought(); $text = _utils_string_at_index($responseValues, 16); if (!is_null($text)) { $text = preg_replace_callback('/\\|([01234567890ABCDEF]{4})/', function ($matches) { return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec($matches[0]))); }, $text); } else { $text = ''; } $responseThought->setText($text); return $responseThought; }