H
H
hollanditkzn2017-08-01 10:41:21
Yii
hollanditkzn, 2017-08-01 10:41:21

How to fix error on hosting?

When I worked on the local, such an error did not come out, when I uploaded it to the site, I got the error Illegal string offset 'message'. Although I did everything according to the documentation, and so I didn’t understand what the error was, should the array be there, or am I doing something wrong?

<?php

namespace frontend\components;

use app\models\User;

$token = 'token';
$webSite = 'https://api.telegram.org/bot'.$token;

$output = file_get_contents('php://input');
$message = $output['message'];
$id = $message['chat']['id'];

$model = User::findOne(\Yii::$app->user->id);
$model->telegram_chat_id = $id;
$model->save();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-08-01
@hollanditkzn

When I worked locally, I didn't get this error.

Customize error_reporting so that such situations do not arise
The error is that $output is not an array, the solution is to add appropriate checks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question