Good afternoon, I've been suffering for a long time, I can't understand what the problem is, why answerInlineQuery doesn't work
It turns out the following, I have a command "InlinequeryCommand.php"
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Entities\InlineQuery\InlineQueryResultArticle;
use Longman\TelegramBot\Entities\InputMessageContent\InputTextMessageContent;
use Longman\TelegramBot\Request;
/**
* Callback query command
*
* This command handles all callback queries sent via inline keyboard buttons.
*
* @see InlinekeyboardCommand.php
*/
class InlinequeryCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'inlinequery';
/**
* @var string
*/
protected $description = 'Reply to inline query';
/**
* @var string
*/
protected $version = '1.1.2';
/**
* Command execute method
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$inline_query = $this->getInlineQuery();
$query = $inline_query->getQuery();
$data = ['inline_query_id' => $inline_query->getId()];
$result = [
'id' => '001',
'title' => '888',
'description' => 'you enter: ' . $query,
'input_message_content' => new InputTextMessageContent(['message_text' => '22' . $query]),
];
$article = new InlineQueryResultArticle($result);
return $this->getInlineQuery()->answer($article, $data);
}
}
When using an inline command, the bot shows the processing of the command, but nothing happens
This is a test command, I tried to figure out how everything works, it turns out that with this command, the user entering any text, should get one article. However nothing happens. Please help me.
inline mode is on
Variable $article have this:
__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'Longman\\TelegramBot\\Entities\\InlineQuery\\InlineQueryResultArticle',
'id' => '001',
'title' => '888',
'description' => 'you enter: ffff',
'input_message_content' =>
__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'Longman\\TelegramBot\\Entities\\InputMessageContent\\InputTextMessageContent',
'message_text' => '22ffff',
'raw_data' =>
array (
'message_text' => '22ffff',
),
'bot_username' => '',
)),
'type' => 'article',
'raw_data' =>
array (
'id' => '001',
'title' => '888',
'description' => 'you enter: ffff',
'input_message_content' =>
__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'Longman\\TelegramBot\\Entities\\InputMessageContent\\InputTextMessageContent',
'message_text' => '22ffff',
'raw_data' =>
array (
'message_text' => '22ffff',
),
'bot_username' => '',
)),
'type' => 'article',
),
'bot_username' => '',
))
I solved this problem just $this->getInlineQuery()->answer($article, $data); replacing with
$results = [];
foreach ($articles as $article) {
$results[] = new InlineQueryResultArticle($article);
}
$inline_query_id = $inline_query->getId();
$cache_time = 0;
$params = compact('inline_query_id', 'results', 'cache_time');
$finish = Request::answerInlineQuery($params);
return $finish;
Most helpful comment
I solved this problem just $this->getInlineQuery()->answer($article, $data); replacing with