I am trying to send emojis via my telegram bot but I can not send it when I take it from an array or a variable.
If I a do this in PHP, it works:
$emoji = "\xF0\x9F\x98\x81";
echo $emoji;
But I want to do something like this:
$emoji = "\xF0\x9F\x98\x81";
$content = array('chat_id' => $id, 'text' => $emoji);
$telegram->sendMessage($content);
Thank you in advance.
UPDATE:
It doesn't show anything.
I've tried with define
and it works, but I need array or variables to do it conditionally.
define(emoji, "\xF0\x9F\x98\x81");
$content = array('chat_id' => $id, 'text' => emoji);
$telegram->sendMessage($content);
I think there is a problem with quotes.
UPDATE2: Problem solved, thanks to these link provided by @CaldwellYSR.
You have to send it this way:
$emoji = "\xE2\x98\x94";
$content = array('chat_id' => $id, 'text' => json_decode('"'.$emoji.'"');
$telegram->sendMessage($content);
Thank you so much.