Telegram Bot Game无法正常工作 [英] Telegram Bot Game not working

查看:225
本文介绍了Telegram Bot Game无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过游戏实现我的机器人电报。
我写了这个:

I am realizing my bot telegram with a game. I wrote this:

$content = file_get_contents("php://input");
$update = json_decode($content, true);
if(!$update)
{
    exit;
}
$chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";

header("Content-Type: application/json");
$parameters = array('chat_id' => $chatId);
$parameters["method"] = "sendGame";
$parameters["game_short_name"] = "prova";
$parameters["text"] = parse_url("<my_html_5_url>");
$message = json_encode($parameters);
echo json_encode($parameters);

我的示例html5代码是:

My sample html5 code is:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Title of the document</title>
    </head>

    <body>
        Content of the document......
    </body>

</html>

当我打电话给游戏时,我只看到Botfather插入的图像,但我没有机会看我的html5。我哪里错了?

When I call the game, I only see the image inserted by Botfather, but I have no chance to see my html5. Where am I wrong?

推荐答案

我这样编辑:

$content = file_get_contents("php://input");
$update = json_decode($content, true);

if(!$update)
{
  exit;
}

$message = isset($update['message']) ? $update['message'] : "";
$messageId = isset($message['message_id']) ? $message['message_id'] : "";
$chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";
header("Content-Type: application/json");

if(isset($update["callback_query"])) {
  $parameters["method"] = "answerCallbackQuery";
  $parameters["callback_query_id"] = $update["callback_query"]["id"];
  $parameters["url"] = "<my_html_5_url>";
  echo json_encode($parameters);

  die;
}
$parameters = array('chat_id' => $chatId);
$parameters["method"] = "sendGame";
$parameters["game_short_name"] = "prova";

echo json_encode($parameters);

这篇关于Telegram Bot Game无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆