电报机器人游戏不工作
Telegram Bot Game not working
我正在用游戏实现我的机器人电报。
我写了这个:
$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 代码是:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body>
Content of the document......
</body>
</html>
当我调用游戏时,我只能看到Botfather插入的图像,但我没有机会看到我的html5。我哪里错了?
我是这样编辑的:
$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);
我正在用游戏实现我的机器人电报。 我写了这个:
$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 代码是:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body>
Content of the document......
</body>
</html>
当我调用游戏时,我只能看到Botfather插入的图像,但我没有机会看到我的html5。我哪里错了?
我是这样编辑的:
$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);