Раньше все прекрасно работало, теперь ошибка:
stdClass Object
(
[error] => stdClass Object
(
[code] => -32000
[message] => Unrecognized error (from tcp:ibe2.iii.ru:2255) [-5]
[data] => stdClass Object
(
)
)
[id] => 0
)
$inf_iii = '5b94f060-570c-434e-980d-6c29608339eb';
$body = 'Привет';
class XORFUNC
{
public static function XOR_encrypt($message, $key)
{
$ml = strlen($message);
$kl = strlen($key);
$newmsg = "";
for ($i = 0; $i < $ml; $i++) {
$newmsg = $newmsg . ($message[$i] ^ $key[$i % $kl]);
}
return base64_encode($newmsg);
}
public static function XOR_decrypt($encrypted_message, $key)
{
$msg = base64_decode($encrypted_message);
$ml = strlen($msg);
$kl = strlen($key);
$newmsg = "";
for ($i = 0; $i < $ml; $i++) {
$newmsg = $newmsg . ($msg[$i] ^ $key[$i % $kl]);
}
return $newmsg;
}
}
function initme($vkid, $key, $botid)
{
$getuid = file_get_contents('http://iii.ru/api/2.0/json/Chat.init/' . $botid . '/' . $vkid);
$jsonparam = json_decode(base64_decode(XORFUNC::XOR_decrypt($getuid, $key)));
return $jsonparam;
}
$config['botid'] = $inf_iii;
$config['url'] = 'http://' . $_SERVER['HTTP_HOST'];
$config['key'] = "some very-very long string without any non-latin characters due to different string representations inside of variable programming languages";
$klush = md5($_SERVER["REMOTE_ADDR"]);
$data = initme(12, $config['key'], $config['botid']);
$session = $data->result->cuid;
$vopros = $body; // Ответ боту
$whattosend = '["' . $session . '","' . urldecode($vopros) . '"]';
$hashed = XORFUNC::XOR_encrypt(base64_encode($whattosend), $config['key']);
$myCurl = curl_init();
curl_setopt_array($myCurl, array(
CURLOPT_URL => 'http://iii.ru/api/2.0/json/Chat.request',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $hashed
));
$response = curl_exec($myCurl);
curl_close($myCurl);
$answer = json_decode(base64_decode(XORFUNC::XOR_decrypt($response, $config['key'])));
$otvet = $answer->result->text->value; // Ответ от бота
echo $otvet;