Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

botan.io error #54

Closed
bercut497 opened this issue Jan 4, 2017 · 4 comments
Closed

botan.io error #54

bercut497 opened this issue Jan 4, 2017 · 4 comments

Comments

@bercut497
Copy link

bercut497 commented Jan 4, 2017

when i enable botan.io by using key in constructor call Client(API_KEY, BOTAN_KEY);
i get loop on webHook. and exceptions in console

2017-01-04T19:25:26.465167+00:00 heroku[router]: at=info method=POST path="/bot.php" host=######################.herokuapp.com request_id=#################################### fwd="###.###.###.###" dyno=web.1 connect=0ms service=653ms status=500 bytes=182
2017-01-04T19:25:26.446538+00:00 app[web.1]: [04-Jan-2017 19:25:26 UTC] PHP Fatal error:  Uncaught Error: Call to a member function toJson() on array in /app/vendor/telegram-bot/api/src/BaseType.php:71
2017-01-04T19:25:26.446764+00:00 app[web.1]: Stack trace:
2017-01-04T19:25:26.446849+00:00 app[web.1]: #0 /app/vendor/telegram-bot/api/src/Botan.php(71): TelegramBot\Api\BaseType->toJson()
2017-01-04T19:25:26.446972+00:00 app[web.1]: #1 /app/vendor/telegram-bot/api/src/Events/EventCollection.php(67): TelegramBot\Api\Botan->track(Object(TelegramBot\Api\Types\Message), 'ping')
2017-01-04T19:25:26.447091+00:00 app[web.1]: #2 /app/vendor/telegram-bot/api/src/Client.php(87): TelegramBot\Api\Events\EventCollection->handle(Object(TelegramBot\Api\Types\Update))
2017-01-04T19:25:26.447178+00:00 app[web.1]: #3 /app/vendor/telegram-bot/api/src/Client.php(100): TelegramBot\Api\Client->handle(Array)
2017-01-04T19:25:26.447236+00:00 app[web.1]: #4 /app/web/bot.php(52): TelegramBot\Api\Client->run()
2017-01-04T19:25:26.447258+00:00 app[web.1]: #5 {main}
2017-01-04T19:25:26.447325+00:00 app[web.1]:   thrown in /app/vendor/telegram-bot/api/src/BaseType.php on line 71
2017-01-04T19:25:26.447432+00:00 app[web.1]: ##.##.##.## - - [04/Jan/2017:19:25:26 +0000] "POST /bot.php HTTP/1.1" 500 5 "-" "-

exception.txt

if i use constructor without BOTAN_KEY all work fine.

bot.php main code :

$bot = new Client(API_KEY, BOTAN_KEY); // exception
//$bot = new Client(API_KEY); //work fine

$bot->command('ping', function (Message $message) use ($bot) {
    $bot->sendMessage( $message->getChat()->getId(), 'pong!' );
});

$bot->run();

bot.php, composer.json, composer.lock in attached zip
botan_io_exceptiondata.zip

@atdtn
Copy link

atdtn commented Feb 10, 2017

The same error.

"PHP message: PHP Fatal error: Call to a member function toJson() on array in vendor/telegram-bot/api/src/BaseType.php on line 71

@akadko
Copy link

akadko commented Mar 30, 2017

The same error.

@cotton-more
Copy link

cotton-more commented Apr 2, 2017

Steps to reproduce:

$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,
        ],
    ],
];

$message = \TelegramBot\Api\Types\Message::fromResponse($response);

$json = $message->toJson();

echo $json;

This is happen since the entities is an array of objects:

Message {#97 ▼
  #messageId: 17
  #from: User {#15 ▶}
  #date: 1491068438
  #chat: Chat {#101 ▶}
  #forwardFrom: null
  #forwardDate: null
  #replyToMessage: null
  #text: "/latest"
  #entities: array:1 [▼
    0 => MessageEntity {#102 ▼
      #type: "bot_command"
      #offset: 0
      #length: 7
      #url: null
    }
  ]
  #audio: null
  #document: null
  #photo: null
  #sticker: null
  #video: null
  #voice: null
  #contact: null
  #location: null
  #venue: null
  #newChatMember: null
  #leftChatMember: null
  #newChatTitle: null
  #newChatPhoto: null
  #deleteChatPhoto: null
  #groupChatCreated: null
  #caption: null
  #supergroupChatCreated: null
  #channelChatCreated: null
  #migrateToChatId: null
  #migrateFromChatId: null
  #pinnedMessage: null
}

@Al-Muhandis
Copy link

The same error.
Appmetrika/botan analitycs shows nothing but my bot is working fine. In apache log:
Fatal error: Call to a member function toJson() on array in /var/www/... .../data/www/... .../... .../vendor/telegram-bot/api/src/BaseType.php on line 71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants