本文整理汇总了PHP中Longman\TelegramBot\Request::answerInlineQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::answerInlineQuery方法的具体用法?PHP Request::answerInlineQuery怎么用?PHP Request::answerInlineQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Longman\TelegramBot\Request
的用法示例。
在下文中一共展示了Request::answerInlineQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$update = $this->getUpdate();
$inline_query = $update->getInlineQuery();
$query = $inline_query->getQuery();
$data = [];
$data['inline_query_id'] = $inline_query->getId();
$articles = [];
$articles[] = ['id' => '001', 'title' => 'D4', 'description' => 'Tetrahedron', 'thumb_url' => 'https://upload.wikimedia.org/wikipedia/commons/1/19/4-sided_dice_250.jpg', 'thumb_width' => 163, 'thumb_height' => 182, 'message_text' => 'You rolled D4: ' . rand(1, 4)];
$articles[] = ['id' => '002', 'title' => 'D6', 'description' => 'Cube', 'thumb_url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Dice_2005.jpg/238px-Dice_2005.jpg', 'thumb_width' => 238, 'thumb_height' => 240, 'message_text' => 'You rolled D6: ' . rand(1, 6)];
$articles[] = ['id' => '003', 'title' => 'D8', 'description' => 'Octahedron', 'thumb_url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/D8_truncated_octahedron.JPG/237px-D8_truncated_octahedron.JPG', 'thumb_width' => 237, 'thumb_height' => 240, 'message_text' => 'You rolled D8: ' . rand(1, 8)];
$articles[] = ['id' => '004', 'title' => 'D10', 'description' => 'Pentagonal', 'thumb_url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/10_sided_die.svg/235px-10_sided_die.svg.png', 'thumb_width' => 235, 'thumb_height' => 240, 'message_text' => 'You rolled D10: ' . rand(1, 10)];
$articles[] = ['id' => '005', 'title' => 'D12', 'description' => 'Dodecahedron', 'thumb_url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/D12_rhombic_dodecahedron.JPG/256px-D12_rhombic_dodecahedron.JPG', 'thumb_width' => 238, 'thumb_height' => 240, 'message_text' => 'You rolled D12: ' . rand(1, 12)];
$articles[] = ['id' => '006', 'title' => 'D20', 'description' => 'Icosahedron', 'thumb_url' => 'https://upload.wikimedia.org/wikipedia/commons/9/97/20-sided_dice_250.jpg', 'thumb_width' => 162, 'thumb_height' => 153, 'message_text' => 'You rolled D20: ' . rand(1, 20)];
$results = [];
foreach ($articles as $key => $value) {
if (stripos($value["title"], $query) !== false) {
$results[] = $value;
}
}
if (count($results) == 0 || (!isset($query) || trim($query) === '')) {
$results = $articles;
}
$array_article = [];
foreach ($results as $article) {
$array_article[] = new InlineQueryResultArticle($article);
}
$array_json = '[' . implode(',', $array_article) . ']';
$data['results'] = $array_json;
$data['cache_time'] = 0;
$result = Request::answerInlineQuery($data);
return $result->isOk();
}
示例2: execute
/**
* {@inheritdoc}
*/
public function execute()
{
$update = $this->getUpdate();
$inline_query = $update->getInlineQuery();
$query = $inline_query->getQuery();
$data = ['inline_query_id' => $inline_query->getId()];
$articles = [['id' => '001', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'message_text' => 'you enter: ' . $query, 'input_message_content' => ['message_text' => $query]], ['id' => '002', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'message_text' => 'you enter: ' . $query, 'input_message_content' => ['message_text' => $query]], ['id' => '003', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'message_text' => 'you enter: ' . $query, 'input_message_content' => ['message_text' => $query]]];
$array_article = [];
foreach ($articles as $article) {
$array_article[] = new InlineQueryResultArticle($article);
}
$data['results'] = '[' . implode(',', $array_article) . ']';
return Request::answerInlineQuery($data);
}
示例3: execute
public function execute()
{
$update = $this->getUpdate();
$inline_query = $update->getInlineQuery();
//$inline_query->getQuery();
//$update->getUpdateId();
$data = array();
$data['inline_query_id'] = $update->getUpdateId();
$data['inline_query_id'] = (string) time();
//$data['cache_time']=60;
//$data['is_personal']="false";
//$data['next_offset']="122;
$data['results'] = '[
{
"type": "article",
"id": "001",
"title": "UC Browser",
"message_text": "Text of the first message",
"parse_mode": "Markdown",
"disable_web_page_preview": true,
"url": "telegram.com",
"hide_url": true,
"description": "Optional. Short description of the result",
"thumb_url": "http://icons.iconarchive.com/icons/martz90/circle/64/uc-browser-icon.png",
"thumb_width": 64,
"thumb_height": 64
},
{
"type": "article",
"id": "002",
"title": "Bitcoin",
"message_text": "*Text of the second message*",
"parse_mode": "Markdown",
"disable_web_page_preview": true,
"url": "bitcoin.org",
"hide_url": true,
"description": "Short description of the result",
"thumb_url": "http://www.coinwarz.com/content/images/bitcoin-64x64.png",
"thumb_width": 64,
"thumb_height": 64
}
]';
$result = Request::answerInlineQuery($data);
return $result->isOk();
//return 1;
}