微信公众号开发——创建自定义菜单(PHP版)

<?php
include "TokenUtil.php";
//TokenUtil::build_access_token();
$access_token = TokenUtil::read_token();

getSucaiList($access_token);

function getSucaiList($token){
    $url = ‘https://api.weixin.qq.com/cgi-bin/menu/create?access_token=‘.$token;
    $Data = ‘{
        "button": [
            {
                "type": "click", 
                "name": "哈哈哈", 
                "key": "V1001_TODAY_MUSIC"
            }, 
            {
                "name": "影视", 
                "sub_button": [
                    {
                        "type": "view", 
                        "name": "搜索", 
                        "url": "http://www.soso.com/"
                    }, 
                    {
                        "type": "click", 
                        "name": "赞一下我们", 
                        "key": "V1001_GOOD"
                    }
                ]
            }
        ]
    };
    //初始化
    $ch = curl_init();
    //设置参数
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt ( $ch, CURLOPT_POST, true );
    curl_setopt ( $ch, CURLOPT_POSTFIELDS, $Data);
    curl_setopt ( $ch, CURLOPT_HEADER, false );
    //采集
    $output = curl_exec($ch);
    
    //关闭
    echo $output;
    curl_close($ch);
}
?>

 

微信公众号开发——创建自定义菜单(PHP版)

上一篇:解决微信转发到朋友圈没有获取页面头像以图标展示。


下一篇:移动应用是大势所趋,微信开发初步研究尝试(图文)