kb0000
kb0000

Reputation: 444

How to read Emoji sent to Telegram Bot in PHP?

I am working on a rating bot. I am showing Keyboards to user to select rating by clicking on stars. User is shown 5 options as Stars. 1 Star, 2 Stars upto 5 Stars (UTF-8 \xE2\xAD\x90). When user clicks on a Star Option then it would be sent to bot. How to read this Star from PHP Code? What would be sent to bot? Will it be '\xE2\xAD\x90' or something else?

Upvotes: 1

Views: 695

Answers (1)

ChicoDelaBarrio
ChicoDelaBarrio

Reputation: 341

This is the string representation for a 'star':

\xe2\xad\x90\xef\xb8\x8f

that I'm getting from my telegram bot. I'm not sure that this is the best way to do it, but I would just count the number of occurrences of that sequence.

Maybe try this on the relevant update from the user:

substr_count($message, '\xe2\xad\x90\xef\xb8\x8'); // returns number of occurrences of a substring

You can use this website to see how emoticons (and strings) look in ut8. If you upload your code I'll good give you a more specific answer.

Upvotes: 1

Related Questions