php - How to send message with telegram inline bots -
i have set webhook , gives me updates, don't know how send inlinequeryresult
php
i want send text this:
aaaaaaaaaaabbbbbbbbbcccccc
how can send php curl? currentry trying:
$token = 'bot###'; $chat_id = '###'; $keyboardl = ['inline_keyboard' => [[['text' => "one", 'callback_data' => "1"],['text' => "two", 'callback_data' => "2"]]]]; $data = array("chat_id" => $chat_id,"results" => "??????","reply_markup" => $keyboardl); $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); echo $result; }
i dont know inlinequeryresult have use in order send text.
to send text inlinequery need use inlinequeryresultarticle
(doc) , therefore set type article
.
you don't need set chat_id
since data automatically gets sent in current active chat. gets identified via inline_query_id
corresponds id
receive in inlinequery
.
$results = array(); $entry = array( "type" => "article", "id" => "1", "title" => "title", "description" => "description", "input_message_content" => array("message_text" => "text sent") ); array_push($results, $entry); $post = array( "inline_query_id" => $queryid, "results" => json_encode($results) ); $ch = curl_init(); curl_setopt($ch, curlopt_url,"https://api.telegram.org/bot" . $token . "/answerinlinequery"); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_postfields, $post); $content = curl_exec ($ch); curl_close ($ch);
Comments
Post a Comment