PhpBotFramework  2.0.2
A framework for Telegram Bots' APIs.
Functions
InlineQueryResults

Handles and stores results before sending them to an answerInlineQuery API call. More...

Functions

 PhpBotFramework\Entities\InlineQueryResults::__construct ()
 
int PhpBotFramework\Entities\InlineQueryResults::addResult (array $result)
 Add a result passing an array containing data. More...
 
int PhpBotFramework\Entities\InlineQueryResults::newArticle (string $title, string $message_text, string $description='', array $reply_markup=null, $parse_mode='HTML', $disable_web_preview=false)
 Add a result of type Article. More...
 
string PhpBotFramework\Entities\InlineQueryResults::get ()
 Get all results created. More...
 

Detailed Description

Handles and stores results before sending them to an answerInlineQuery API call.

In order to answer inline queries: create an object of type PhpBotFramework and add the wanted results using InlineQueryResults::addResult() method or type-based result method (InlineQueryResults::newArticle()).

use PhpBotFramework\Entities\InlineQueryResults;
use PhpBotFramework\Entities\InlineQuery;
~
~
~
    processInlineQuery(InlineQuery $inline_query) {
        $handler = new InlineQueryResults();
        $handler->newArticle('First article', 'This is the first result');

        $this->answerInlineQuery($handler->get());
    }

Function Documentation

◆ __construct()

PhpBotFramework\Entities\InlineQueryResults::__construct ( )

Create an InlineQueryResult object.

◆ addResult()

int PhpBotFramework\Entities\InlineQueryResults::addResult ( array  $result)

Add a result passing an array containing data.

Create a result of one of these types:

  • InlineQueryResultCachedAudio
  • InlineQueryResultCachedDocument
  • InlineQueryResultCachedGif
  • InlineQueryResultCachedMpeg4Gif
  • InlineQueryResultCachedPhoto
  • InlineQueryResultCachedSticker
  • InlineQueryResultCachedVideo
  • InlineQueryResultCachedVoice
  • InlineQueryResultArticle
  • InlineQueryResultAudio
  • InlineQueryResultContact
  • InlineQueryResultGame
  • InlineQueryResultDocument
  • InlineQueryResultGif
  • InlineQueryResultLocation
  • InlineQueryResultMpeg4Gif
  • InlineQueryResultPhoto
  • InlineQueryResultVenue
  • InlineQueryResultVideo
  • InlineQueryResultVoice

To add a result, create an array containing data as showed on API Reference, 'id' parameter will be automatically genereted so there is no need to add it.

Example of adding an article result:

$data = [
    'type' => 'result',
    'title' => 'Example title',
    'message_text' => 'Text of the message'
];

$handler->addResult($data);
Parameters
array$resultArray containing data result to add.
Returns
int Id of the result added.

◆ get()

string PhpBotFramework\Entities\InlineQueryResults::get ( )

Get all results created.

Returns
string JSON string containing the results.

◆ newArticle()

int PhpBotFramework\Entities\InlineQueryResults::newArticle ( string  $title,
string  $message_text,
string  $description = '',
array  $reply_markup = null,
  $parse_mode = 'HTML',
  $disable_web_preview = false 
)

Add a result of type Article.

Add a result that will be show to the user.

Parameters
string$titleTitle of the result.
string$message_textText of the message to be sent.
string$descriptionOptional. Short description of the result
array$reply_markupInline keyboard object. Not JSON serialized, use getArray from InlineKeyboard class.
string$parse_modeOptional. Formattation style for the message.
string$disable_web_previewOptional. Disables link previews for links in the sent message.
Returns
int Id the the article added.