微信公眾號開發——創建自定義菜單(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);
}
?>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM