TELEGRAMBOT如何获得ChosenInlineResult

时间:2016-07-20 13:33:58

标签: php telegram-bot

如何在此结果中获取ChosenInlineResult? : 我正在使用PHP,这是我的发送结果页面

 $results = array(
            array(
                "type" => "article",
                "id" => "1",
                "title" => "aaaa",
                "description" => "bbbb",
                "input_message_content" => array(
                    "message_text" => "mt",
                    "parse_mode" => "HTML"
                ),"reply_markup" => array('inline_keyboard' => ($keyboardx))
            )
        );
  $data = array(
        "inline_query_id" => $qid,
        "results" => json_encode($results),
        "cache_time" => 0
    );

    $data_string = json_encode($data);
    $ch = curl_init('https://api.telegram.org/'.$token.'/answerInlineQuery');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($data_string))
    );
    $result = curl_exec($ch);
file_put_contents("res.txt",$result,FILE_APPEND);

这里我将保存返回的数据在res.txt

1 个答案:

答案 0 :(得分:4)

您需要转到BotFather并将/setinlinefeedback设置为Enabled才能收到ChosenInlineResult。之后,当InlineQueryResult被选中时,您会收到ChosenInlineResult的消息。

{
    "update_id" : 123456789,
    "chosen_inline_result" : {
        //[...]
    }
}