Как убрать баг Call to undefined function mb_strtolower?

Создал либу для бота ВК....
Как всегда всё не работает:

MicroEngineVK.php

<?php
include 'config.php'; // Config

class MicroEngineVK {
	/* [Import config] */
	// @VK PARAMS
	protected static $VK_CONFIRMATION_TOKEN = VK_CONFIRMATION_TOKEN; // @VK CONFIRMATION TOKEN
	protected static $VK_TOKEN = VK_TOKEN; // @VK TOKEN
	protected static $VK_SECRET_KEY = VK_SECRET_KEY; // @VK TOKEN
	protected static $VK_API_VERSION = VK_API_VERSION; // @VK TOKEN
	// @VK_BOT PARAMS
	protected $BOT_FAILED_ANSWER = BOT_FAILED_ANSWER; // @VK_BOT FAILED ANSWER
	protected static $BOT_NAME = BOT_NAME; // @VK_BOT NAME
	protected static $BOT_V = BOT_VERSION; // @VK_BOT VERSION
	// @VK TYPE
	protected static $VK_TYPE_CONFIRMATION = VK_TYPE_CONFIRMATION; // @VK_BOT_TYPE CONFIRMATION REQUEST
	protected static $VK_TYPE_NEW_MESSAGE = VK_TYPE_NEW_MESSAGE; //@VK_BOT_TYPE NEW MESSAGE REQUEST

	/* [Other] */
	public $data, $USER_ID, $PEER_ID, $RANDOM_ID, $USER_TEXT, $USER_NAME, $BOT_ANSWER, $BOT_COMMANDS; // @VK_BOT DATA
	public $VCF = [
		'Привет | Hi' => [
			'Привет, !{user_name}!!!! Тебя приветствует бот !{bot_name} версии !{bot_version}',
			'Опять вы.... Ну, hi....'
		],
	]; // @VK_BOT FAQ

	function __construct(){
		$this->MicroEngineVK_INIT();
	}

	public function MicroEngineVK_INIT(){
		$this->data = json_decode(file_get_contents('php://input'));
		if(!isset($this->data)) exit;
		if(strcmp($this->data->secret, MicroEngineVK::$VK_SECRET_KEY) !== 0 && strcmp($this->data->type, MicroEngineVK::$VK_TYPE_CONFIRMATION) !== 0) return;

		$this->USER_ID = $this->data->object->user_id;
		$this->PEER_ID = $this->data->object->peer_id;
		$this->RANDOM_ID = $this->data->object->random_id;
		$this->USER_TEXT = mb_strtolower($this->data->object->text);
		$this->USER_INFO = json_decode(file_get_contents('https://api.vk.com/method/users.get?user_ids='.$this->USER_ID.'&access_token='.MicroEngineVK::$VK_TOKEN.'&v='.MicroEngineVK::$VK_API_VERSION.''));
		$this->USER_NAME = $USER_INFO->response[0]->first_name;
	}

	public function MicroEngineVK_Confirmation (){ // Confirmation Bot
		echo MicroEngineVK::$VK_CONFIRMATION_TOKEN;
	}

	public function MicroEngineVK_New_Message(){ // NEW_MESSAGE
		if(strlen($this->USER_TEXT) > 1){ // Check User Text
			foreach ($this->VCF as $question => $answer) {
				$res = strpos(mb_strtolower($question), mb_strtolower($this->USER_TEXT));
				if($res !== false){
					$this->BOT_ANSWER = $answer[array_rand($answer)];
				}
			}
		}

		$this->BOT_ANSWER = [ // @VK_BOT BOT COMMANDS
			'!{user_name}' => $this->USER_NAME,
			'!{bot_name}' => MicroEngineVK::$BOT_NAME,
			'!{bot_version}' => MicroEngineVK::$BOT_VERSION
		];

		if($this->BOT_ANSWER != MicroEngineVK::$BOT_FAILED_ANSWER and strpos($this->BOT_ANSWER, '!{') != false){
			foreach ($this->BOT_COMMANDS as $command => $val) {
				$this->BOT_ANSWER = str_replace($command, $val, $this->BOT_ANSWER);
			}
		}

		$params = http_build_query([
			'message' => $this->BOT_ANSWER,
			'peer_id' => $this->PEER_ID,
			'user_id' => $this->USER_ID,
			'random_id' => $this->RANDOM_ID,
			'access_token' => MicroEngineVK::$VK_TOKEN,
			'v' => MicroEngineVK::$VK_API_VERSION
		]);

		file_get_contents('https://api.vk.com/method/messages.send?' . $params);

		echo 'ok';
	}

	public function MicroEngineVK_Start_Bot(){ // Start Bot
		switch ($this->data->type) {
			case MicroEngineVK::$VK_TYPE_CONFIRMATION:
				$this->MicroEngineVK_Confirmation();
				break;

			case MicroEngineVK::$VK_TYPE_NEW_MESSAGE:
				$this->MicroEngineVK_New_Message();
				break;
		}
	}
}
?>


config.php

<?php
// TYPES
define('VK_TYPE_CONFIRMATION', 'confirmation');
define('VK_TYPE_NEW_MESSAGE', 'message_new');

// BOT PARAMS
define('BOT_NAME', 'NameBot');
define('BOT_VERSION', '0.0.1');
define('BOT_FAILED_ANSWER', 'Бот не нашёл ответа на ваш вопрос!');


bot.php

<?php

include 'MicroEngineVK.php'; // Config

$core = new MicroEngineVK (); // Init Core for bot
$core->MicroEngineVK_Start_Bot(); // Start Bot МЛ

?>


логи

PHP Notice:  Undefined property: stdClass::$user_id in /app/MicroEngineVK.php on line 37
2019-07-04T11:33:58.305411+00:00 app[web.1]: [04-Jul-2019 11:33:58 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mb_strtolower() in /app/MicroEngineVK.php:40


Как пофиксить и что нужно изменить?
  • Вопрос задан
  • 862 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы