phptelegramtelegram-botphp-telegram-bot

How to send emoji (not custom) throw the Telegram API


I tried few variants. Like here:

How to send Emoji with Telegram Bot API?

python telegram telethon how to send emoji

And each variant of encoding from this page https://www.fileformat.info/info/unicode/char/1f4b5/index.htm

But nothing helped for me.

I tried to escape backslashes and to not. So I get this U0001F609 or this \U0001F609 in Telegram message.

Can somebody just show me JSON which I have to send in order to finally receive a smiley in the message?


Solution

  • So, I see that in telegrams you need to send emoji as a UTF-8 entity (i.e. 🗂 / 💵, etc.).

    But my problem was that the text that the bot sends is regulated from the site's admin panel and stored in the database. And in the table, I cannot change the encoding for the correct storage of such characters (I get ???? at the output).

    The solution I came up with:

    Right now I'm storing an HTML entity in the database (i.e. 🔝 / &#128181 etc.) and before sending the message, I cut them out of the regular expression /&#.*;/mU and convert to correct encoding with mb_convert_encoding($match, 'UTF-8', 'HTML-ENTITIES')

    I did not describe all these points in the original message because I myself did not fully understand why the telegram does not process what I am trying to send to it.