码迷,mamicode.com
首页 > 微信 > 详细

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

时间:2017-06-25 23:12:16      阅读:363      评论:0      收藏:0      [点我收藏+]

标签:key   curl   output   .com   field   cli   php   logs   create   

<?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版)

标签:key   curl   output   .com   field   cli   php   logs   create   

原文地址:http://www.cnblogs.com/dige1993/p/7078362.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!