Core: An error when calling a \TelegramBot\Api\Types\Message::toJson

Created on 2 Apr 2017  Β·  3Comments  Β·  Source: php-telegram-bot/core

Required Information

  • PHP version: PHP 7.0.15
  • PHP Telegram Bot version: 2.2.7

  • Using MySQL database: no

  • Update Method: getUpdates
  • Self-signed certificate: no
  • RAW update (if available):

Expected behaviour

Calling \TelegramBot\Api\Types\Message::toJson of an object with a non-empty entities filed should return a json-string

Actual behaviour

An erro Call to a member function toJson() on array

Steps to reproduce

  1. Create a response array
    $response = [
        "message_id" => 17,
        "from" => [
            "id" => 142775991,
            "first_name" => "first name",
            "last_name" => "last name",
            "username" => "nickname",
        ],
        "chat" => [
            "id" => 142775991,
            "first_name" => "first name",
            "last_name" => "last name",
            "username" => "nickname",
            "type" => "private",
        ],
        "date" => 1491068438,
        "text" => "/latest",
        "entities" => [
            [
                "type" => "bot_command",
                "offset" => 0,
                "length" => 7,
            ],
        ],
    ];
  1. Create a message from a response
    $message = \TelegramBot\Api\Types\Message::fromResponse($response);
  1. Dump the message into a json-string
    $json = $message->toJson();
  1. Got an error since $this->$property->toJson(true) is called for a field entities which is an array

Most helpful comment

sith-happens-hd-vector

All 3 comments

Wrong repo, mate....
НС Ρ‚ΠΎΡ‚ Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠΉ - Ρ‚Π²ΠΎΠΉ Π±ΠΎΡ‚ Π½Π° Π΄Ρ€ΡƒΠ³ΠΎΠΌ скриптС собран...

Π‘ΠΎΡ€Ρ€ΠΈ, слишком ΠΌΠ½ΠΎΠ³ΠΎ Π²ΠΊΠ»Π°Π΄ΠΎΠΊ ΠΎΡ‚ΠΊΡ€Ρ‹Π».

sith-happens-hd-vector

Was this page helpful?
0 / 5 - 0 ratings

Related issues

noplanman picture noplanman  Β·  3Comments

sayjeyhi picture sayjeyhi  Β·  3Comments

nesttle picture nesttle  Β·  4Comments

dorcu picture dorcu  Β·  3Comments

sineverba picture sineverba  Β·  3Comments