telegram bot keyboard + emoji buttons tutorial - IT NEWS

Latest

Programming PHP tutorials for beginners. Technology and product reviews.

Monday, May 8, 2017

telegram bot keyboard + emoji buttons tutorial

Adv
telegram bot emoji

telegram bot tutorial

How to make custom location for telegram bot buttons?
You can use this example. New array for next button lines.


$keyboard = array(
'keyboard' => array(
array(
"button", "one",
"two", "three"
),
array(
"Currency",
"Menu"
),
array(
"1", "2", "3"
),
array(
"4"
)
),
'resize_keyboard' => true,
'one_time_keyboard' => false
);
$postfields = array(
'chat_id' => "$chatid",
'text' => "$reply",
'reply_markup' => json_encode($keyboard)
);


Array ( [chat_id] => 263142423 [text] => Working [reply_markup] => {"keyboard":[["button","one","two","three"],["Currency","Menu"],["1","2","3"],["4"]],"resize_keyboard":true,"one_time_keyboard":false} )

telegram bot emoji


How to make emoji buttons?

Emoji keyboard for Telegram bot PHP script with Json
You can take emoji codes here: http://www.charbase.com/block/miscellaneous-symbols-and-pictographs click on Icon, then copy Java Escape emoji code and insert as button text. array("Text \ud83d\ude08", " Text 2 \ud83d\udcaa", "\ud83d\udcf2")
PHP example with curl telegram API:

$botid = "******BOT_ID";
$chatid = "*****Telegram Chat_ID";
$reply = "Working";
$url = "https://api.telegram.org/bot$botid/sendMessage";
$keyboard = array(
'keyboard' => array(
array(
"button",
"\ud83d\ude08",
"\ud83d\udcaa",
"\ud83d\udcf2"
),
array(
"Currency",
"Menu"
),
array(
"1", "2", "3"
),
array(
"4"
)
),
'resize_keyboard' => true,
'one_time_keyboard' => false
);
$postfields = array(
'chat_id' => "$chatid",
'text' => "$reply",
'reply_markup' => json_encode($keyboard)
);

$str = str_replace('\\\\', '\\', $postfields);

print_r($str);
if (!$curld = curl_init()) {
exit;
}

curl_setopt($curld, CURLOPT_POST, true);
curl_setopt($curld, CURLOPT_POSTFIELDS, $str);
curl_setopt($curld, CURLOPT_URL,$url);
curl_setopt($curld, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($curld);

curl_close ($curld);
with this telegram bot request example you will see this: Array ( [chat_id] => 26313453 [text] => Working [reply_markup] => {"keyboard":[["button","\ud83d\ude08","\ud83d\udcaa","\ud83d\udcf2"],["Currency","Menu"],["1","2","3"],["4"]],"resize_keyboard":true,"one_time_keyboard":false} )

telegram bot emoji

also you can just add emoji from standard Mac keyboard as text:
telegram bot emoji

https://www.facebook.com/chakabiz
https://www.youtube.com/channel/UCYuMRNb_SRZ4FMsZjnHRZUA

No comments:

Post a Comment