F
F
FastClick2019-08-20 14:29:04
PHP
FastClick, 2019-08-20 14:29:04

Notice error, what's the problem?

Error: Notice : Undefined property: stdClass::$
text

{"type":"message_new","object":{"date":1566299943,"from_id":1234668,"id":649,"out":0,"peer_id":12345668,"text":"Бот","conversation_message_id":28,"fwd_messages":[],"important":false,"random_id":0,"attachments":[],"is_hidden":false},"group_id":12344567}

The code itself:
$data = json_decode(file_get_contents('php://input')); 

 
echo 'ok'; 
 

$id = $data->object->from_id; // Узнаем ID пользователя, кто написал нам 
$message = $data->object->text; // Само сообщение от пользователя ОШИБКУ БЬЕТ НА ЭТОЙ СТРОКЕ (text)!
 
if ($data->type == 'message_new') { 
 if ($message == 'Бот') { 
 $vk->sendMessage($id, "Привет:)"); 
}
 } 
 
 
 }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FastClick, 2019-08-20
@FastClick

Problem solved! The error was in the version of Api vk, it was 5.101, set it to 5.87, everything worked, thanks to everyone :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question