微信解决昵称乱码的问题
下载网络开源代码,对昵称进行转义https://github.com/iamcal/php-emoji
测试代码如下:
<link href="php-emoji-master/emoji.css" rel="stylesheet" type="text/css" /> <?php /** * Created by PhpStorm. * User: _fdy * Date: 2015/8/24 * Time: 16:50 */ $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxYT0b248f58042db26c&secret=0cYT34675f629601689713ce7444779046"; $result = file_get_contents($url); $arr = json_decode($result); $access_token =$arr->access_token; $openid = "oNQe7jtxVO1012ZO1S237LZnUPU0YT"; $url2 = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=".$access_token."&openid=".$openid; $result2 = json_decode(file_get_contents($url2)); include('./php-emoji-master/emoji.php'); $data = base64_encode($result2->nickname); $str = base64_decode($data); echo emoji_unified_to_html($str); |