当前位置:主页 >> 移动开发 >> 正文
微信开发自定义菜单示例文档
阅读:1328 输入:2015-06-28 16:45:44
<?php
header("Content-type: text/html; charset=utf-8");
$APPID='wx1aabc8673b8f103a';
$APPSECRET='9aa99fc9db9bf1321c1afe05feb29b6c';

$jsondata=file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$APPID."&secret=".$APPSECRET);
$weixindata=json_decode($jsondata);
$ACCESS_TOKEN=$weixindata->access_token;


$info_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$ACCESS_TOKEN}&openid={$APPID}&lang=zh_CN";


//$info_url="https://api.weixin.qq.com/cgi-bin/menu/create?access_token={$ACCESS_TOKEN}";
$ch = curl_init();


$data = '{"button":[{"type":"click","name":"获取密码1","key":"get_password"},{"type":"click","name":"解锁账户","key":"unlock_acount"}]}';

echo $info_url;echo "<br />";

curl_setopt($ch, CURLOPT_URL,$info_url);
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);
?>