-
Notifications
You must be signed in to change notification settings - Fork 175
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
What is this error for keyboard ? #98
Comments
I think this may be an error in the code. I'll look into it tonight ;) Thanks for reporting this! |
Hey |
Is the error because of PHP 7.2 ? |
PD: This was the script I used: <?php
declare(strict_types = 1);
include __DIR__.'/basics.php';
use React\EventLoop\Factory;
use unreal4u\TelegramAPI\HttpClientRequestHandler;
use unreal4u\TelegramAPI\Telegram\Methods\SendMessage;
use unreal4u\TelegramAPI\TgLog;
$loop = Factory::create();
$tgLog = new TgLog(BOT_TOKEN, new HttpClientRequestHandler($loop));
$sendMessage = new SendMessage();
$sendMessage->chat_id = A_USER_CHAT_ID;
//$sendMessage->chat_id = $chatId;
$sendMessage->text = "<code>◀️دکمه های اصلی▶️</code>";
$sendMessage->parse_mode = 'HTML';
$sendMessage->reply_markup = new \unreal4u\TelegramAPI\Telegram\Types\ReplyKeyboardMarkup();
$sendMessage->reply_markup->resize_keyboard = true;
$keyboardButton = new \unreal4u\TelegramAPI\Telegram\Types\KeyboardButton();
$keyboardButton->text = '🎤یک';
$sendMessage->reply_markup->keyboard[0][] = $keyboardButton;
$keyboardButton = new \unreal4u\TelegramAPI\Telegram\Types\KeyboardButton();
$keyboardButton->text = '⛽️دو';
$sendMessage->reply_markup->keyboard[0][] = $keyboardButton;
$keyboardButton = new \unreal4u\TelegramAPI\Telegram\Types\KeyboardButton();
$keyboardButton->text = '➕سه';
$sendMessage->reply_markup->keyboard[1][] = $keyboardButton;
$keyboardButton = new \unreal4u\TelegramAPI\Telegram\Types\KeyboardButton();
$keyboardButton->text = '📩چهار';
$sendMessage->reply_markup->keyboard[1][] = $keyboardButton;
$keyboardButton = new \unreal4u\TelegramAPI\Telegram\Types\KeyboardButton();
$keyboardButton->text = '📘پنج';
$sendMessage->reply_markup->keyboard[2][] = $keyboardButton;
$tgLog->performApiRequest($sendMessage);
$promise = $tgLog->performApiRequest($sendMessage);
$promise->then(
function ($response) {
echo '<pre>';
var_dump($response);
echo '</pre>';
},
function (\Exception $exception) {
// Onoes, an exception occurred...
echo 'Exception ' . get_class($exception) . ' caught, message: ' . $exception->getMessage();
}
);
$loop->run(); It is based on this one: https://github.com/unreal4u/telegram-api/blob/master/examples/send-message-with-inlinekeyboard.php But with your modifications in it, the only thing I did replace was the chatId due to obvious reasons :) |
Add this after the above code:
I removed this my problem solved! I discovered If you send message after a message that has keyboard you face that fatal error. |
I think that if you initialize a new object you won't have the issue: if($chatId == A_USER_CHAT_ID) {
$sendMessage = new SendMessage();
$sendMessage->chat_id = A_USER_CHAT_ID;
$sendMessage->text = '%D9%86%D9%87%0A%D8%AF%D8%A7%D8%B1%DB%8C%D9%85+%D8%B3%D8%B1%D9%88%D8%B1%D8%B4';
$sendMessage->parse_mode = 'HTML';
$tgLog->performApiRequest($sendMessage);
$loop->run();
} |
No difference |
unreal4u/telegram-api v3.4.1 A complete Telegram ...
PHP Version: 7.2
Output:
When I use this code:
I face the Fatal error above.
What is wrong ?
The text was updated successfully, but these errors were encountered: