How to send Emoji with Telegram Bot API? How to send Emoji with Telegram Bot API? php php

How to send Emoji with Telegram Bot API?


I faced the same issue a few days ago..The solution is to use Bytes (UTF-8) notation from this table:http://apps.timwhitlock.info/emoji/tables/unicode

examples:

😁 \xF0\x9F\x98\x81 GRINNING FACE WITH SMILING EYES

😉 \xF0\x9F\x98\x89 WINKING FACE


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.


See emojis and their UTF-8 codes here:http://apps.timwhitlock.info/emoji/tables/unicode

Then you must convert UTF-8 codes to Telegram-ready response text with the following code:

<?phpfunction telegram_emoji($utf8emoji) {    preg_replace_callback(        '@\\\x([0-9a-fA-F]{2})@x',        function ($captures) {            return chr(hexdec($captures[1]));        },        $utf8emoji    );    return $utf8emoji;}$utf8emoji = '\xF0\x9F\x98\x81';$telegramReadyResponse = 'Hi user ' . telegram_emoji($utf8emoji);