哪位大神告訴我下為啥我的微信菜單欄中文里面顯示的是%A這種形式
? ? public ?function defineItem(){
? ? ? ? header('content-type:text/html;charset=utf-8');
? ? ? ? $access_token= getWxAccessToken();
? ? ? ? $url="https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$access_token;
?
$postArr=array(
? ? ? ? ? ? 'button'=>array(
? ? ? ? ? ? ? ? array(
? ? ? ? ? ? ? ? ? ? 'name'=>urlencode('a1'),
? ? ? ? ? ? ? ? ? ? 'type'=>'click',
? ? ? ? ? ? ? ? ? ? 'key'=>'item1',
? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? array(
? ? ? ? ? ? ? ? ? ? 'name'=>urlencode('a2'),
? ? ? ? ? ? ? ? ? ? 'sub_button'=>array(
? ? ? ? ? ? ? ? ? ? ? ? array(
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'name'=>urlencode('歌曲'),
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'type'=>'click',
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'key'=>'songs'
? ? ? ? ? ? ? ? ? ? ? ? ),//第一個(gè)二級(jí)菜單
? ? ? ? ? ? ? ? ? ? ? ? array(
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'name'=>urlencode('電影'),
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'type'=>'view',
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'url'=>'http://www.baidu.com'
? ? ? ? ? ? ? ? ? ? ? ? ),//第二個(gè)二級(jí)菜單
? ? ? ? ? ? ? ? ? ? )
? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? array(
? ? ? ? ? ? ? ? ? ? 'name'=>urlencode('a3'),
? ? ? ? ? ? ? ? ? ? 'type'=>'view',
? ? ? ? ? ? ? ? ? ? 'url'=>'http://www.qq.com',
? ? ? ? ? ? ? ? ),//第三個(gè)一級(jí)菜單
? ? ? ? ));
? ? ? ? $postJson=json_encode($postArr);
? ? ? ??
? ? ? ? $res = $this->http_curl($url,'post','json',$postJson);
? ? ? ?
}
public function http_curl($url,$type='get',$res='json',$arr=''){
? ? ? ? //1.初始化curl
? ? ? ? $ch ?=curl_init();
? ? ? ? //2.設(shè)置curl的參數(shù)
? ? ? ? curl_setopt($ch,CURLOPT_URL,$url);
? ? ? ? curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
? ? ? ? if($type == 'post'){
? ? ? ? ? ? curl_setopt($ch,CURLOPT_POST,1);
? ? ? ? ? ? curl_setopt($ch,CURLOPT_POSTFIELDS,$arr);
? ? ? ? }
? ? ? ? //3.采集
? ? ? ? $output =curl_exec($ch);
? ? ? ? //4.關(guān)閉
? ? ? ? curl_close($ch);
? ? ? ? if($res=='json'){
? ? ? ? ? ? if(curl_error($ch)){
? ? ? ? ? ? ? ? //請(qǐng)求失敗,返回錯(cuò)誤信息
? ? ? ? ? ? ? ? return curl_error($ch);
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? //請(qǐng)求成功,返回錯(cuò)誤信息
? ? ? ? ? ? ? ? return json_decode($output,true);
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? echo var_dump( $output );
? ? } ?
2016-10-22
$postJson=json_encode($postArr);這里改成$postJson = ?urldecode(json_encode( $postArr ) );