0

0

微信开发Emoji表情的实例教程

Y2J

Y2J

发布时间:2017-05-13 14:36:16

|

3673人浏览过

|

来源于php中文网

原创

一 什么是emoji  

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

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

Emoji 全编码表:
punchdrunker.github.com/iOSEmoji/table_html/flower.html

code.iamcal.com/php/emoji/

 回复代码如下所示:

25175企业客户管理系统2.5.1
25175企业客户管理系统2.5.1

25175企业客户管理系统能够方便的录入新的信息例如新的项目、新增客户等同时能够清楚的管理一些款项结算。由于功能的强大,用户可以在该系统上发表文章后让员工递交工作计划或工作报告。加强企业工作效率,为企业提高实力。因为该系统可由客户、程序员、负责人等身份登入 所以适合广大企业使用。管理首页:{信息录入|信息修改|信息查询}1信息录入:你可以根据实际情况进行以下操作 1-1新的项目

下载
responseMsg();
}else{    $wechatObj->valid();
}class wechatCallbackapiTest
{    //验证签名
    public function valid()
    {        $echoStr = $_GET["echostr"];        $signature = $_GET["signature"];        $timestamp = $_GET["timestamp"];        $nonce = $_GET["nonce"];        $token = TOKEN;        $tmpArr = array($token, $timestamp, $nonce);        sort($tmpArr, SORT_STRING);        $tmpStr = implode($tmpArr);        $tmpStr = sha1($tmpStr);        if($tmpStr == $signature){            header('content-type:text');            echo $echoStr;            exit;
        }
    }    //响应消息
    public function responseMsg()
    {        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];        if (!empty($postStr)){            $this->logger("R \r\n".$postStr);            $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);            $RX_TYPE = trim($postObj->MsgType);         
            
            //消息类型分离
            switch ($RX_TYPE)
            {                case "event":                    $result = $this->receiveEvent($postObj);                    break;                case "text":                    $result = $this->receiveText($postObj);                    break;               
                default:                    $result = "unknown msg type: ".$RX_TYPE;                    break;
            }            $this->logger("T \r\n".$result);            echo $result;
        }else {            echo "";            exit;
        }
    }    //接收事件消息
    private function receiveEvent($object)
    {        $content = "";        switch ($object->Event)
        {            case "subscribe":                $content = "欢迎关注方倍工作室 ";                break;            case "unsubscribe":                $content = "取消关注";                break;            case "CLICK":                switch ($object->EventKey)
                {                    case "COMPANY":                        $content = array();                        $content[] = array("Title"=>"方倍工作室", "Description"=>"", "PicUrl"=>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958");                        break;                    default:                        $content = "点击菜单:".$object->EventKey;                        break;
                }                break;            default:                $content = "receive a new event: ".$object->Event;                break;
        }        if(is_array($content)){            if (isset($content[0]['PicUrl'])){                $result = $this->transmitNews($object, $content);
            }else if (isset($content['MusicUrl'])){                $result = $this->transmitMusic($object, $content);
            }
        }else{            $result = $this->transmitText($object, $content);
        }        return $result;
    }    //接收文本消息
    private function receiveText($object)
    {        $keyword = trim($object->Content);        //多客服人工回复模式
        if (strstr($keyword, "请问在吗") || strstr($keyword, "在线客服")){            $result = $this->transmitService($object);            return $result;
        }        //自动回复模式
        if (strstr($keyword, "文本")){            $content = "这是个文本消息";
        }else if (strstr($keyword, "表情")){            $content = "中国:".$this->bytes_to_emoji(0x1F1E8).$this->bytes_to_emoji(0x1F1F3)."\n仙人掌:".$this->bytes_to_emoji(0x1F335);
        }else if (strstr($keyword, "单图文")){            $content = array();            $content[] = array("Title"=>"单图文标题",  "Description"=>"单图文内容", "PicUrl"=>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958");
        }else if (strstr($keyword, "图文") || strstr($keyword, "多图文")){            $content = array();            $content[] = array("Title"=>"多图文1标题", "Description"=>"", "PicUrl"=>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958");            $content[] = array("Title"=>"多图文2标题", "Description"=>"", "PicUrl"=>"http://d.hiphotos.bdimg.com/wisegame/pic/item/f3529822720e0cf3ac9f1ada0846f21fbe09aaa3.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958");            $content[] = array("Title"=>"多图文3标题", "Description"=>"", "PicUrl"=>"http://g.hiphotos.bdimg.com/wisegame/pic/item/18cb0a46f21fbe090d338acc6a600c338644adfd.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958");
        }else if (strstr($keyword, "音乐")){            $content = array();            $content = array("Title"=>"最炫民族风", "Description"=>"歌手:凤凰传奇", "MusicUrl"=>"http://121.199.4.61/music/zxmzf.mp3", "HQMusicUrl"=>"http://121.199.4.61/music/zxmzf.mp3"); 
        }else{            $content = date("Y-m-d H:i:s",time())."\nOpenID:".$object->FromUserName."\n技术支持 方倍工作室";            // $content = "";        }        if(is_array($content)){            if (isset($content[0])){                $result = $this->transmitNews($object, $content);
            }else if (isset($content['MusicUrl'])){                $result = $this->transmitMusic($object, $content);
            }
        }else{            $result = $this->transmitText($object, $content);
        }        return $result;
    }    //回复文本消息
    private function transmitText($object, $content)
    {        if (!isset($content) || empty($content)){            return "";
        }        $xmlTpl = "
    
    
    %s
    
    
";        $result = sprintf($xmlTpl, $object->FromUserName, $object->ToUserName, time(), $content);        return $result;
    }    //回复图文消息
    private function transmitNews($object, $newsArray)
    {        if(!is_array($newsArray)){            return "";
        }        $itemTpl = "        
            <![CDATA[%s]]>
            
            
            
        ";        $item_str = "";        foreach ($newsArray as $item){            $item_str .= sprintf($itemTpl, $item['Title'], $item['Description'], $item['PicUrl'], $item['Url']);
        }        $xmlTpl = "
    
    
    %s
    
    %s
    $item_str    
";        $result = sprintf($xmlTpl, $object->FromUserName, $object->ToUserName, time(), count($newsArray));        return $result;
    }    //回复音乐消息
    private function transmitMusic($object, $musicArray)
    {        if(!is_array($musicArray)){            return "";
        }        $itemTpl = "
        <![CDATA[%s]]>
        
        
        
    ";        $item_str = sprintf($itemTpl, $musicArray['Title'], $musicArray['Description'], $musicArray['MusicUrl'], $musicArray['HQMusicUrl']);        $xmlTpl = "
    
    
    %s
        $item_str";        $result = sprintf($xmlTpl, $object->FromUserName, $object->ToUserName, time());        return $result;
    }    //字节转Emoji表情
    function bytes_to_emoji($cp)
    {        if ($cp > 0x10000){       # 4 bytes
            return chr(0xF0 | (($cp & 0x1C0000) >> 18)).chr(0x80 | (($cp & 0x3F000) >> 12)).chr(0x80 | (($cp & 0xFC0) >> 6)).chr(0x80 | ($cp & 0x3F));
        }else if ($cp > 0x800){   # 3 bytes
            return chr(0xE0 | (($cp & 0xF000) >> 12)).chr(0x80 | (($cp & 0xFC0) >> 6)).chr(0x80 | ($cp & 0x3F));
        }else if ($cp > 0x80){    # 2 bytes
            return chr(0xC0 | (($cp & 0x7C0) >> 6)).chr(0x80 | ($cp & 0x3F));
        }else{                    # 1 byte
            return chr($cp);
        }
    }    //日志记录
    private function logger($log_content)
    {        if(isset($_SERVER['HTTP_APPNAME'])){   //SAE
            sae_set_display_errors(false);
            sae_debug($log_content);
            sae_set_display_errors(true);
        }else if($_SERVER['REMOTE_ADDR'] != "127.0.0.1"){ //LOCAL
            $max_size = 1000000;            $log_filename = "log.xml";            if(file_exists($log_filename) and (abs(filesize($log_filename)) > $max_size)){unlink($log_filename);}            file_put_contents($log_filename, date('Y-m-d H:i:s')." ".$log_content."\r\n", FILE_APPEND);
        }
    }
}?>

【相关推荐】

 1. 特别推荐“php程序员工具箱”V0.1版本下载

2. 微信公众号平台源码下载

3. 阿狸子订单系统源码下载

相关文章

微信app下载
微信app下载

微信是一款手机通信软件,支持通过手机网络发送语音短信、视频、图片和文字。微信可以单聊及群聊,还能根据地理位置找到附近的人,带给大家全新的移动沟通体验,有需要的小伙伴快来保存下载体验吧!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
虚拟号码教程汇总
虚拟号码教程汇总

本专题整合了虚拟号码接收验证码相关教程,阅读下面的文章了解更多详细操作。

29

2025.12.25

错误代码dns_probe_possible
错误代码dns_probe_possible

本专题整合了电脑无法打开网页显示错误代码dns_probe_possible解决方法,阅读专题下面的文章了解更多处理方案。

20

2025.12.25

网页undefined啥意思
网页undefined啥意思

本专题整合了undefined相关内容,阅读下面的文章了解更多详细内容。后续继续更新。

37

2025.12.25

word转换成ppt教程大全
word转换成ppt教程大全

本专题整合了word转换成ppt教程,阅读专题下面的文章了解更多详细操作。

6

2025.12.25

msvcp140.dll丢失相关教程
msvcp140.dll丢失相关教程

本专题整合了msvcp140.dll丢失相关解决方法,阅读专题下面的文章了解更多详细操作。

2

2025.12.25

笔记本电脑卡反应很慢处理方法汇总
笔记本电脑卡反应很慢处理方法汇总

本专题整合了笔记本电脑卡反应慢解决方法,阅读专题下面的文章了解更多详细内容。

6

2025.12.25

微信调黑色模式教程
微信调黑色模式教程

本专题整合了微信调黑色模式教程,阅读下面的文章了解更多详细内容。

5

2025.12.25

ps入门教程
ps入门教程

本专题整合了ps相关教程,阅读下面的文章了解更多详细内容。

4

2025.12.25

苹果官网入口直接访问
苹果官网入口直接访问

苹果官网直接访问入口是https://www.apple.com/cn/,该页面具备0.8秒首屏渲染、HTTP/3与Brotli加速、WebP+AVIF双格式图片、免登录浏览全参数等特性。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

218

2025.12.24

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
Node.js 教程
Node.js 教程

共57课时 | 7.4万人学习

Rust 教程
Rust 教程

共28课时 | 3.8万人学习

Vue 教程
Vue 教程

共42课时 | 5.5万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号