微信4001錯誤原因
為了獲取用戶信息,我寫了個函數
    /**
     * 獲取用戶信息
     * @return 
array 
    */
    function get_user_info($openid, $access_token, $lang = 
"zh_CN")
    {
        $arr = array(); $json = null;
        $url = 
"https://api.weixin.qq.com/cgi-bin/user/info?access_token=
$access_token&openid=$openid&lang=$lang";
   
     while(!$json)
        {
            $json = 
file_get_contents($url);
        }
        $arr = 
json_decode($json,true);    
        return $arr;    
   
 }
API文檔中卻說這里的access_token參數與基礎的access_token不同,
於是我傳遞了用戶級的access_token,結果始終是40001錯誤,一晚上沒搞出來。
第二天很無奈的傳遞了一下全局的access_token,竟然意外的成功獲取了用戶信息,
我心里面淚流滿面!
所以在用戶授權后獲取用戶公開信息的時候,
access_token參數傳遞的是全局的access_token,
而不是用戶級的ccess_token。
在此把這個問題記錄一下以免忘記。
