Vlmake Vlmake - 1 month ago 48
PHP Question

How to send Emoji with Telegram Bot API?

I need to send messages containing emoji with my Telegram Bot.

So I copy/paste emoji code

:nine:
for example, in my message text and send it to a user, BUT emoji didn`t work.

This is my sample code and function:

function tel_send($key, $t, $c)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.telegram.org/bot" . $key . "/sendMessage");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "cache=" . (time() / rand(1, time() - 100)) . "&text=" . $t . "&chat_id=" . $c);
$ss = curl_exec($ch);
curl_close($ch);
return $ss;
}
tel_send($key, "My number - :nine:", $val['message']['chat']['id']);


So, my question is: How can I send emoji by Telegram bot?

Answer

you need to specify emoji's unicode value.

check here

these are returned by a function as emoji value like u'\U000026C4' which is snowman. although it is in python, you can apply it for php.

Comments