PDA

View Full Version : دریافت مقدار بازگشتی از inline_keyboard تلگرام



hamedg1366
جمعه 03 آذر 1396, 11:25 صبح
با سلام


بنده با این نمونه کد دکمه ها رو می سازم اما نمیتونم مقداری رو کاربر روش کلیلک میکنه رو در بازگشت بدست بیارم ؛ لطفا منو راهنامئی بفرمائید :






<?php

$con=mysqli_connect("localhost",...);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
ini_set('default_charset',"UTF-8");
mysqli_set_charset($con,"UTF8");

$message = file_get_contents("php://input");
$arrayMessage = json_decode($message, true);


$token = "...";
$chat_id = $arrayMessage['message']['from']['id'];
$command = $arrayMessage['message']['text'];


if ($command == '/start') {

$text = "سلام ، خوش آمدید";
$url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chat_id . "&text=" . $text;
file_get_contents($url);

$keyboard = [
'inline_keyboard'=>[
[
['text'=>'Google','callback_data' => 'Google'],['text'=>'Yahoo!','callback_data' => 'Yahoo']
] , // سطر اول
[
['text'=>'MhrDeveloper','url'=>'https://www.google.com/']
] ,// سطر دوم
[
['text'=>'Peyman','callback_data' => 'P3YM4N']
] //سطر سوم

] , "one_time_keyboard" => true
];
$encodedKeyboard = json_encode($keyboard);

$url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chat_id . "&text=" . "Ejad Button" . "&parse_mode=HTML&reply_markup=$encodedKeyboard";
file_get_contents($url);
}




?>