<?php
require_once dirname(__FILE__).'/jiazai.php';
header("Content-type: text/html; charset=utf-8");
header("Content-type: text/html; charset=gb2312");
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=*********************&secret=*****************************";
$content = file_get_contents($url);
$info = json_decode($content);
print_r($info);
echo $info->access_token;
$ACCESS_TOKEN=$info->access_token;
$data = '{
"button": [
{
"name": "徐州亿网",
"sub_button": [
{
"type": "view",
"name": "亿网首页",
"url": "http://sjz.exz.cn/"
},
{
"type": "view",
"name": "软件定制",
"url": "http://sjz.exz.cn/sjrj.aspx"
},
{
"type": "view",
"name": "客户端定制",
"url": "http://sjz.exz.cn/khdzz.aspx"
},
{
"type": "view",
"name": "WAP站定制",
"url": "http://sjz.exz.cn/sjwap.aspx"
},
{
"type": "view",
"name": "客户案例",
"url": "http://sjz.exz.cn/case.aspx"
}
]
}
],
"button": [
{
"name": "徐州亿网",
"sub_button": [
{
"type": "view",
"name": "亿网首页",
"url": "http://sjz.exz.cn/"
},
{
"type": "view",
"name": "软件定制",
"url": "http://sjz.exz.cn/sjrj.aspx"
},
{
"type": "view",
"name": "客户端定制",
"url": "http://sjz.exz.cn/khdzz.aspx"
},
{
"type": "view",
"name": "WAP站定制",
"url": "http://sjz.exz.cn/sjwap.aspx"
},
{
"type": "view",
"name": "客户案例",
"url": "http://sjz.exz.cn/case.aspx"
}
]
}
],
"button": [
{
"name": "在线服务",
"sub_button": [
{
"type": "view",
"name": "投诉与建议",
"url": "http://www.soso.com/"
},
{
"type": "view",
"name": "满意度调查",
"url": "http://v.qq.com/"
},
{
"type": "CLICK",
"name": "测试三",
"key": "V1001_GOOD"
}
]
}
]
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={$ACCESS_TOKEN}");
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)) {
echo 'Errno'.curl_error($ch);
}
curl_close($ch);
var_dump($tmpInfo);
?>