how to send emoji emoticons via Telegram API?
In the official documentation not a word about emoticons. Somewhere they write that you need to send UTF-8
emoticon code. … but it’s all useless
U + 1F601
U1F601
# 1F601;
& amp; # 1F601;
\ xF0 \ x9F \ x98 \ x81
Answer 1, authority 100%
Take a look at Emoji Unicode Tables .
The emoticon code you need is in the Bytes (UTF-8)
column.
URL Encode must be performed before sending to server.
For example, \ xF0 \ x9F \ x98 \ x81
should look like this: % F0% 9F% 98% 81
.
Answer 2, authority 36%
I just copied the emoji from tables above with normal mouse selection (how the text is highlighted) from the column “Native” it turns out like this: 😜
Answer 3, authority 36%
On bash I use this resource to get the code
The line “C / C++ / Java source code” displays the required encoding.
The request takes the form
/ usr / local / bin / curl -s --header 'Content-Type: application / json' --request ' POST '--data "{\" chat_id \ ": \" - 432111111 \ ", \" text \ ": \" \ uD83D \ uDC4C - Here is OK emoji \ "}" "https: //api.telegram. org / bot & lt; TOKEN & gt; / sendMessage "
where \ uD83D \ uDE31
is the encoded character 👌
Answer 4, authority 27%
I am writing a bot in C #, it works like this "\ U0001F69A"
for the code U + 1F69A
from the table.
Answer 5
For PHP where the smiley is:
hex2bin ('f09f9880') & lt; br & gt;
f09f9880
– emoticon code without \ x
from here (column Bytes (UTF-8)
)
Answer 6
Use tools to represent Unicode text in your environment. It will perform the conversion from text to octets according to the utf-8 encoding itself, and then perform percent -encoding . For example, to send a flag 🇷🇺, which consists of Unicode characters U + 1f1f7 , U + 1f1fa in restclient in Emacs :
POST https://api.telegram.org/bot:token/sendMessage
Content-type: application / x-www-form-urlencoded
chat_id =: chat-id & amp; text = hooray 🇷🇺!
This makes an http POST request to the specified url (bot identified by : token
sends a message hurray 🇷🇺!
to : chat-id
chat ).
In Python, this might look like this:
import requests
requests.post (f'https: //api.telegram.org/bot {token} / sendMessage ',
dict (chat_id = chat_id, text = 'hurray 🇷🇺!'))
It can be seen that there is no need to manually encode the string into the ascii representation:
'\ u0443 \ u0440 \ u0430 \ U0001f1f7 \ U0001f1fa!'
Python will automatically encode the message. Goes to the server (encrypted using TLS), something like:
POST / bot & lt; token & gt; / sendMessage HTTP / 1.1
Host: api.telegram.org
User-Agent: python-requests / 2.18.4
Accept-Encoding: gzip, deflate
Accept: * / *
Connection: keep-alive
Content-Length: 69
Content-Type: application / x-www-form-urlencoded
chat_id = & lt; chat-id & gt; & amp; text =% D1% 83% D1% 80% D0% B0 +% F0% 9F% 87% B7% F0% 9F% 87% BA% 21