Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Sending emojis #48

Closed
Bizkaitarra opened this issue Oct 29, 2015 · 7 comments
Closed

Sending emojis #48

Bizkaitarra opened this issue Oct 29, 2015 · 7 comments

Comments

@Bizkaitarra
Copy link

Hi,

First of all thanks for your code and work, it makes very easy to make a bot.

I want to send emojis and I can't see how to do it.

I've sent to a log file all messages I recive and I sent in the conversation with the bot. Then I sent to the bot all the emojis I want. Then I tried to resent the message I recived and the emoji was shown.

But, when I try to send the text I have in my log file, it doesn't work at all...

My log:
2015-10-29 8:48:31 Jontxu ha puesto lo siguiente : \ud83d\udc4e\n\n"

In my code I tried all I find:

$data['text'] .= "\n" . '\ud83d\udc4e\n\n'

OR

$data['text'] .= "\n" . utf8_encode('\ud83d\udc4e\n\n')

OR

$data['text'] .= "\n" . utf8_decode('\ud83d\udc4e\n\n')

OR as I have read here: http://stackoverflow.com/questions/31279158/unicode-characters-like-emoticons-in-telegram-bot-message-or-keyboard

$data['text'] .= "\n" . '\xF0\x9F\x91\x8E'

Can you please give me a clue?

Thanks!

@MBoretto
Copy link
Collaborator

Hello!
Should work with:

$emoticons = "\ud83d\udc4e";
$data['text'] =  "your text ".json_decode('"'.$emoticons.'"').' bla bla';

@Bizkaitarra
Copy link
Author

It works!

Thanks one more time 👍

I've done a IRC Trivial like bot and with emojis will look better!!! :)

@NabiKAZ
Copy link
Contributor

NabiKAZ commented Jun 5, 2017

And so can use here:
http://apps.timwhitlock.info/emoji/tables/unicode
Bytes column directly.
For example:

$data['text'] = "\xF0\x9F\x91\x8D"; // :thumbsup:

important: must use into double quotation.

@noplanman
Copy link
Member

Or better yet, just use a proper dedicated library:
spatie/emoji

@NabiKAZ
Copy link
Contributor

NabiKAZ commented Jun 5, 2017

@noplanman Requires php: ^7.0 is stringent.

@noplanman
Copy link
Member

True, as should any serious project nowadays.
PHP 7+ should be standard now, best upgrade if you can 👍

@IgorUsoltsev
Copy link

Double quote was my solution

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants