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?
inside your onNotificationProcessing method(For emoji in notification body, use setContentText). Send notification with emoji replaced with Unicode. Also, add <emoji> before and after your Unicode(this is to identify emoji inside the application).
Go to Chat Settings and scroll down to Quick Reaction. In there, you'll find a list of emoji available for use. Select the one you want.
Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a local photo by passing a file path.
It is only possible to send messages to users whom have already used /start on your bot. When they start your bot, you can find update. message.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With