用PHP转换微信中的emoji表情

aries 发表于 2015-02-13 4417 次浏览

emoji就是表情符号;词义来自日语(えもじ,e-moji,moji在日语中的含义是字符)表情符号现已普遍应用于手机短信和网络聊天软件。emoji表情符号,在外国的手机短信里面已经是很流行使用的一种表情。

在国内的微信和微信中也被采用。



![emoji.png](https://qn-cdn.jianbokeji.net/2015/02/13/1642181081.png) 



[Emoji]() 全编码表:



[http://punchdrunker.github.com/iOSEmoji/table_html/flower.html](http://punchdrunker.github.com/iOSEmoji/table_html/flower.html) 



所用的到开源库:



[http://code.iamcal.com/php/emoji/](http://code.iamcal.com/php/emoji/) 



用法:
<?php
include('emoji.php');
//解析微信发送的请求
$datas = file_get_contents('php://input');
$posts = simplexml_load_string($datas, 'SimpleXMLElement', LIBXML_NOCDATA);
//微信发送的内容为
$content = $posts->Content;
$clean_text = emoji_docomo_to_unified($content );
$html = emoji_unified_to_html($clean_text);
echo $html;

解析出来的$html为

<span class="emoji emoji1f609"></span>

所以你还要在输出表情的页面载入emoji.css。还有一张emoji.png需要和emoji.css在同一目录

0条评论

如需评论,请填写表单。
换一个

记住我的信息