irazasyed/telegram-bot-sdk

PHP Fatal error: Uncaught exception

skorotkiewicz opened this issue · 1 comments

aue@aaak:~/telegram-bot-sdk# php stest.php 
PHP Fatal error:  Uncaught exception 'Irazasyed\Telegram\Exceptions\TelegramUndefinedPropertyException' in /aue/telegram-bot-sdk/src/Objects/BaseObject.php:144
Stack trace:
#0 /aue/telegram-bot-sdk/stest.php(13): Irazasyed\Telegram\Objects\BaseObject->__call('getLastName', Array)
#1 /aue/telegram-bot-sdk/stest.php(13): Irazasyed\Telegram\Objects\User->getLastName()
#2 {main}
  thrown in /aue/telegram-bot-sdk/src/Objects/BaseObject.php on line 144
aue@aaak:~/telegram-bot-sdk# cat stest.php 
<?php

$loader = require __DIR__.'/vendor/autoload.php';

use Irazasyed\Telegram\Telegram;

$telegram = new Telegram('XX:XX');

$response = $telegram->getMe();

$botId = $response->getId();
$firstName = $response->getFirstName();
$lastName = $response->getLastName();
$username = $response->getUsername();

echo $botId . ' ' . $firstName . ' ' . $lastName . ' ' . $username;

Actually, Bots don't have last name. So you need not use getLastName(). I've removed from the README example as well.

LastName will be available for the actual user though. So you can remove that and it'll work fine.