douduan6731 2019-04-19 20:26 采纳率: 0%
浏览 102

无法自定义inline_keyboard

the problem is next, can't customize sizes of inline buttons in telegram. Want them to be entirely shown stretched with no shortage. "resize_keyboard" => true doesn't helped. Stuck there, any suggestions, guys?

I suppose code is correct

$init_msg='Приветствую вас в чат-боте "Я В ЗП"';

function sendRequest($params,$replyMarkup){
    if(!empty($params)){
        file_put_contents(__DIR__.'/log_responses.txt',  file_get_contents(BASE_URL.'sendMessage?'.http_build_query($params).'&reply_markup=' . $replyMarkup), FILE_APPEND);
    }else{
        printf('check parameters');
    }
}

        $chat_id=$updates['message']['chat']['id'];
        //domTreeHandler returns parsed array, takes XPath query as parameter
    $keyboard_test=array("inline_keyboard"=>[domTreeHandler('//*[contains(@class,"article-intro")][p]')],'resize_keyboard' => true);
    $replyMarkupTest=json_encode($keyboard_test, JSON_UNESCAPED_UNICODE);


    sendRequest(['chat_id'=>$chat_id,'text'=>$init_msg], $replyMarkupTest);

Texted query is next

https://api.telegram.org/bot781684063:<TELEGRAM API HERE>?chat_id=323989110&text=%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82%D1%81%D1%82%D0%B2%D1%83%D1%8E+%D0%B2%D0%B0%D1%81+%D0%B2+%D1%87%D0%B0%D1%82-%D0%B1%D0%BE%D1%82%D0%B5+%22%D0%AF+%D0%92+%D0%97%D0%9F%22&reply_markup={"inline_keyboard":[[{"text":" Комунальний заклад охорони здоров'я «Міська стоматологічна поліклініка №3»69096, бул.Вінтера, 22","callback_data":"\/help"},{"text":" Заклад охорони здоров'я «Дитяча міська стоматологічна поліклініка»69035,вул. Кам'яногірська, 5","callback_data":"\/help"},{"text":" Комунальна установа «Міська стоматологічна поліклініка № 6»вул.Фільтрова,1","callback_data":"\/help"},{"text":" Комунальна установа «Міська стоматологічна поліклініка №2»69002, вул. Шкільна, 46","callback_data":"\/help"},{"text":" Комунальне Некомерційне Підприємство «Стоматологічна поліклініка №7» Запорізької Міської Радина Чумаченка, 40\/8","callback_data":"\/help"},{"text":" Комунальна установа «Міська стоматологічна поліклініка №4»69057, вул. Сєдова, 10","callback_data":"\/help"},{"text":" Комунальне підприємство «Міська стоматологічна поліклініка №5»69098, вул. Бочарова,12","callback_data":"\/help"}]],"resize_keyboard":true}

Output is

  • 写回答

1条回答 默认 最新

  • dougang6178 2019-04-20 18:24
    关注

    If someone interested, solution was just place each inline button to their own square brackets. Instead of

    "inline_keyboard":[
    [{"button1":" text1","callback_data":"/1"},
    {"button2":" text2","callback_data":"/2"}]] 
    

    had to be

    "inline_keyboard":[
    [{"button1":" text1","callback_data":"/1"}],
    [{"button2":" text2","callback_data":"/2"}]]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题