/*请求的url地址*/
define("ACCESS_TOKEN",'5DvptZBk8XSjPH98L1wHq4AqyS6u4jJ1gQKDU8VbZrSWBlPpjlg99zScxzg7e7_ah4todKSS543IHZrE_8KbuvB2SXMsSFfYQIFX_V73P2gOUTbAJAION');
$url="https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".ACCESS_TOKEN;
/*模拟发送post请求*/
/*1.初始化*/
$ch=curl_init();
/*2.设置curl*/
curl_setopt($ch, CURLOPT_URL, $url);
/*捕获内容 不输出*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/*模拟发送post请求*/
curl_setopt($ch, CURLOPT_POST, 1);
/*发送相关数据*/
$data='{
"button":[
{
"type":"view",
"name":"微博客",
"url":"http://blog.lampol-blog.com:8080"
},
{
"type":"click",
"name":"文章中心",
"key":"article"
},
{
"type":"click",
"name":"关于我们",
"key":"aboutus"
}]
}';
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
/*禁止服务器端校检ssl证书文件*/
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
/*执行*/
$output=curl_exec($ch);
if($output===false){
echo curl_error($ch);
}else{
echo $output;
}
/*关闭*/
curl_close($ch);
一键复制
编辑
Web IDE
原始数据
按行查看
历史