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

微信企业号生成菜单栏

时间:2016-07-01 16:11:58      阅读:701      评论:0      收藏:0      [点我收藏+]

标签:

一、

技术分享
 
二、
技术分享
 
三、
技术分享
 
四、
技术分享
 
五、
技术分享
 
六、
技术分享
七、
技术分享
八、
技术分享
九、
<?php
header("Content-type: text/html; charset=utf-8");
define("ACCESS_TOKEN", ‘wx2PjXrVLMOlOAPiWt3solXPe_vC69UTzY2IbpNqgFR_dQ_pEJ_3x3o46tfEtnLm‘);
function weixinPost($data){
        $ch = curl_init(); //初始化
        //设置参数
         curl_setopt($ch, CURLOPT_URL, "https://qyapi.weixin.qq.com/cgi-bin/menu/create?access_token=".ACCESS_TOKEN."&agentid=4");//设施url参数
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");//设置请求method参数
         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)) {//如果错误,输出一下
          return curl_error($ch);
         }
         curl_close($ch);//关闭
         return $tmpInfo;
    }
    
$data = ‘{
    "button": [
        {
            "name": "说说",
            "sub_button": [
                {
                    "type": "view",
                    "name": "搞笑说说",
                    "url":"http://www.soso.com/"
                },
                {
                    "type": "view",
                    "name": "爱情说说",
                    "url":"http://www.soso.com/"
                },
                {
                    "type": "view",
                    "name": "职场说说",
                    "url":"http://www.soso.com/"
                },
                {
                    "type": "view",
                    "name": "励志说说",
                    "url":"http://www.soso.com/"
                },
                {
                    "type": "view",
                    "name": "心情说说",
                    "url":"http://www.soso.com/"
                }
            ]
        },
        {
            "name": "文章",
            "sub_button": [
                {
                    "type": "view",
                    "name": "健身文章",
                    "url":"http://www.baidu.com/"
                 },
                {
                    "type": "view",
                    "name": "养生文章",
                    "url":"http://www.baidu.com/"
                },
                {
                    "type": "view",
                    "name": "互联网文章",
                    "url":"http://www.baidu.com/"
                },
                {
                    "type": "view",
                    "name": "教育文章",
                    "url":"http://www.baidu.com/"
                },
                {
                    "type": "view",
                    "name": "法律文章",
                    "url":"http://www.baidu.com/"
                }
            ]
        },{
            "name": "心情说",
            "sub_button": [
                {
                    "type": "view",
                    "name": "首页",
                    "url":"http://www.baidu.com/"
                 },
                {
                    "type": "view",
                    "name": "关于我们",
                    "url":"http://www.baidu.com/"
                }
            ]
        }
    ]
}‘;
    $tmpInfo = weixinPost($data);  
    echo $tmpInfo;
?>

微信企业号生成菜单栏

标签:

原文地址:http://www.cnblogs.com/chen5421/p/5633092.html

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