电报错误的内联键盘错误400不良请求

发布于 2025-02-05 15:44:33 字数 602 浏览 2 评论 0原文

我想发送一个编码键盘作为回复标记,但我会收到错误400不好的requset!

这就是JSON的样子:

{"inline_keyboard":[[{"text":"Play, Guitar, Play - \u003Cspan style=\"font-size:14px;\"\u003E Conway Twitty ","callback_data":"some url"}]]}

这就是代码的样子:

 // Create keyboard
    $keyboard = json_encode([
        "inline_keyboard" => [
            $innerdata,
    ]], true);

    $url = "https://api.telegram.org/bot$token/sendMessage?chat_id=$chat_id&text=Choose&reply_markup=".$keyboard;
    $res = file_get_contents($url); 
        break;

我还尝试删除其中一个[] [] ,但它不起作用。

I wanna send a json encoded keyboard as reply markup but I get error 400 bad requset!

This is how json looks like:

{"inline_keyboard":[[{"text":"Play, Guitar, Play - \u003Cspan style=\"font-size:14px;\"\u003E Conway Twitty ","callback_data":"some url"}]]}

and this is how the code looks like:

 // Create keyboard
    $keyboard = json_encode([
        "inline_keyboard" => [
            $innerdata,
    ]], true);

    $url = "https://api.telegram.org/bot$token/sendMessage?chat_id=$chat_id&text=Choose&reply_markup=".$keyboard;
    $res = file_get_contents($url); 
        break;

I've also tried deleting one of the [ ] but it didn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

行雁书 2025-02-12 15:44:37

我实际上发现了问题。这是数据大小的问题。正如Telegram所说,回调数据不应超过64个字节

,并且可以通过:

if(strlen($callback_data) < 64){
//the rest of the code
}

I actually find the problem. It was a problem with data size. As Telegram says, the callback data should not be more than 64 bytes

And it can be fixed by:

if(strlen($callback_data) < 64){
//the rest of the code
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文