1. 程式人生 > >微信建立選單報 must use utf-8 charset hint 錯誤

微信建立選單報 must use utf-8 charset hint 錯誤

<?php
    include '../WeiXinApi/WeiXinApi.php';
    //建立選單.
    $access_token= getToken();
    if ($access_token =='-1')
    {
        echo ("get token failed");
        exit();
    }
    $getCreatMenuUrl='https://api.weixin.qq.com/cgi-bin/menu/create?access_token='.$access_token;
    $jsonStr= '{"button":[{"type":"click","name":"今日歌曲","key":"V1001_TODAY_MUSIC"},{"name":"選單","sub_button":[{"type":"view","name":"搜尋","url":"http://www.soso.com/"},{"type":"click","name":"贊一下我們","key":"V1001_GOOD"}]}]}';
    
//$jsonStr=json_encode($jsonStr,JSON_UNESCAPED_UNICODE); $responsJson=http_post_json($getCreatMenuUrl, $jsonStr); echo ($responsJson[0] . $responsJson[1]); ?>

這是因為本身windows平臺檔案是不是預設utf-8格式的, 另存為把檔案改成utf-8格式.. 執行正確.