function create_menu($data){
$ch = curl_init();//设置选项,包括URL
curl_setopt($ch, CURLOPT_URL,"https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" .$this->get_token());
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);//使用https
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
if(!empty($json_str)){
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
}
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$output = curl_exec($ch);//执行并获取HTML文档内容
if(curl_errno($ch)){// 返回最后一次的错误号
return curl_error($ch); //返回一个保护当前会话最近一次错误的字符串
}
curl_close($ch);//释放curl句柄
return $output;
}
public function get_menu(){
header('Content-type:text/html;charset=utf-8');
$result=file_get_contents("https://api.weixin.qq.com/cgi-bin/menu/get?access_token=".$this->get_token());
return $result;
}
public function del_menu(){
$result=file_get_contents("https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=".$this->getToken());
return $result;
}
function create_xin_menu($data){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=".$this -> getToken());
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch);
if (curl_errno($ch)) {
返回curl_error($ch);
}
curl_close($ch);
$json_arr = (array)json_decode($tmpInfo);
if(array_key_exists('menuid',$json_arr)){
return $json_arr['menuid'];
}else{
return false;
}
}
}##$wx=new WX();
$wx->create_menu($data);
$arr=array(
'button'=>array(
array(
'类型'=>'点击',
'名称'=>'每日新闻',
'key'=>'V1001_XIN_WEN'
),
array(
'name'=>'综合',
'sub_button'=>array(
array(
'name'=>'音乐',
' type'=>'view',
'url'=>'http://s.music.so.com/s?src=relation_music&q=%E6%B5%81%E8%A1%8C'
),
数组(
'名称'=>'搞笑',
'类型'=>'视图',
'url'=>'https:// v.qq.com/x/channel/fun'
)
),
),
array(
'name'=>'学习',
'sub_button'=>array(
array(
'name'=>'php中文网',
'type'=>'view',
'url'=>'//m.sbmmt.com/'
),
),
)
),
);
$data =json_encode($arr, JSON_UNESCAPED_UNICODE);
$data 在哪呢,你没传