一、
二、
三、
四、
五、
六、
七、
八、
九、
<?php
header("Content-type: text/html; charset=utf-8");
define("ACCESS_TOKEN", ‘wx2PjXrVLMOlOAPiWt3solXPe_vC69UTzY2IbpNqgFR_dQ_pEJ_3x3o46tfEtnLm‘);
function weixinPost($data){
$ch = curl_init(); //初始化
//设置参数
curl_setopt($ch, CURLOPT_URL, "https://qyapi.weixin.qq.com/cgi-bin/menu/create?access_token=".ACCESS_TOKEN."&agentid=4");//设施url参数
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");//设置请求method参数
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)) {//如果错误,输出一下
return curl_error($ch);
}
curl_close($ch);//关闭
return $tmpInfo;
}
$data = ‘{
"button": [
{
"name": "说说",
"sub_button": [
{
"type": "view",
"name": "搞笑说说",
"url":"http://www.soso.com/"
},
{
"type": "view",
"name": "爱情说说",
"url":"http://www.soso.com/"
},
{
"type": "view",
"name": "职场说说",
"url":"http://www.soso.com/"
},
{
"type": "view",
"name": "励志说说",
"url":"http://www.soso.com/"
},
{
"type": "view",
"name": "心情说说",
"url":"http://www.soso.com/"
}
]
},
{
"name": "文章",
"sub_button": [
{
"type": "view",
"name": "健身文章",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "养生文章",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "互联网文章",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "教育文章",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "法律文章",
"url":"http://www.baidu.com/"
}
]
},{
"name": "心情说",
"sub_button": [
{
"type": "view",
"name": "首页",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "关于我们",
"url":"http://www.baidu.com/"
}
]
}
]
}‘;
$tmpInfo = weixinPost($data);
echo $tmpInfo;
?>
header("Content-type: text/html; charset=utf-8");
define("ACCESS_TOKEN", ‘wx2PjXrVLMOlOAPiWt3solXPe_vC69UTzY2IbpNqgFR_dQ_pEJ_3x3o46tfEtnLm‘);
function weixinPost($data){
$ch = curl_init(); //初始化
//设置参数
curl_setopt($ch, CURLOPT_URL, "https://qyapi.weixin.qq.com/cgi-bin/menu/create?access_token=".ACCESS_TOKEN."&agentid=4");//设施url参数
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");//设置请求method参数
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)) {//如果错误,输出一下
return curl_error($ch);
}
curl_close($ch);//关闭
return $tmpInfo;
}
$data = ‘{
"button": [
{
"name": "说说",
"sub_button": [
{
"type": "view",
"name": "搞笑说说",
"url":"http://www.soso.com/"
},
{
"type": "view",
"name": "爱情说说",
"url":"http://www.soso.com/"
},
{
"type": "view",
"name": "职场说说",
"url":"http://www.soso.com/"
},
{
"type": "view",
"name": "励志说说",
"url":"http://www.soso.com/"
},
{
"type": "view",
"name": "心情说说",
"url":"http://www.soso.com/"
}
]
},
{
"name": "文章",
"sub_button": [
{
"type": "view",
"name": "健身文章",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "养生文章",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "互联网文章",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "教育文章",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "法律文章",
"url":"http://www.baidu.com/"
}
]
},{
"name": "心情说",
"sub_button": [
{
"type": "view",
"name": "首页",
"url":"http://www.baidu.com/"
},
{
"type": "view",
"name": "关于我们",
"url":"http://www.baidu.com/"
}
]
}
]
}‘;
$tmpInfo = weixinPost($data);
echo $tmpInfo;
?>