Inserting emoji in tweet and message from php


#1

Hi,
All I want is to insert emoji in a tweet or in a message from a php script. The problem is that I can’t understand how I should encode the unicode character.

I found the emoji codes here: http://apps.timwhitlock.info/emoji/tables/unicode
I know that the text must be UTF-8 encoded and I already know how to send a normal tweet or message, but I just don’t understand how to append an emoji.
Maybe it’s just a little thing…

Thanks in advance!


#2

Don’t use php - but this looks like it: https://secure.php.net/manual/en/migration70.new-features.php#migration70.new-features.unicode-codepoint-escape-syntax so "\u{1F63A}" for :smiley_cat: emoji etc.


#3

Hi, thanks for the help!
Maybe that should work on php 7 but I’ve php 5.6 and for me it doesn’t work.

I’ve tried this:
echo html_entity_decode('😉', 0, 'UTF-8');
and I could see the winking face on the browser

so i tried to append that to the text that will be sent to the API:
$TEXT="@twitterapi trying to tweet an emoji from php script: "; $TEXT=utf8_encode($TEXT).html_entity_decode('😉', 0, 'UTF-8');

And i got this:

https://twitter.com/3R_LikeNoOther/status/703344309513428992

So I solved it and i hope that it will be helpful for somebody else too! :wink: :wink: :wink: