微信企业号创建自定义菜单

微信企业号创建菜单

<?php
define('CorpID',        "wx82e2c31215d9a5a7");
define('CorpSecret',    ""); //当前管理组 设置->功能设置->权限管理->系统管理组->深圳管理(新建的管理组)->Secret
define('AgentID',        "24");     //当前应用ID


require_once("../../class/wxqiye.class.php");
$weixin = new class_wxqiye();

$button = array(array('name' => "点击跳转",
                      'sub_button' => array(
                                        array('type' => "click",
                                              'name' => bytes_to_emoji(0x1F3C3)."点击推事件",
                                              'key'  => "COMPANY"
                                              ),
                                        array('type' => "view",
                                              'name' => bytes_to_emoji(0x1F4C5)."跳转URL",
                                              'url'  => "http://www.fangbei.org/"
                                             ),
                                    )
                      ),
                array('name' => "扫码发图",
                      'sub_button' => array(
                                        array('type' => "scancode_waitmsg",
                                              'name' => "扫码带提示",
                                              'key'  => "rselfmenu_2_1"
                                              ),
                                        array('type' => "scancode_push",
                                              'name' => "扫码推事件",
                                              'key'  => "rselfmenu_2_2"
                                              ),
                                        array('type' => "pic_sysphoto",
                                              'name' => "系统拍照发图",
                                              'key'  => "rselfmenu_2_3"
                                              ),
                                        array('type' => "pic_photo_or_album",
                                              'name' => "拍照或相册发图",
                                              'key'  => "rselfmenu_2_3"
                                              ),
                                        array('type' => "pic_weixin",
                                              'name' => "微信相册发图",
                                              'key'  => "rselfmenu_2_5"
                                              )
                                    )
                      ),
                array('type' => "location_select",
                      'name' => "发送位置",
                      'key'  => "rselfmenu_3_0",
                      )
                );
function bytes_to_emoji($cp)
{
    if ($cp > 0x10000){       # 4 bytes
        return chr(0xF0 | (($cp & 0x1C0000) >> 18)).chr(0x80 | (($cp & 0x3F000) >> 12)).chr(0x80 | (($cp & 0xFC0) >> 6)).chr(0x80 | ($cp & 0x3F));
    }else if ($cp > 0x800){   # 3 bytes
        return chr(0xE0 | (($cp & 0xF000) >> 12)).chr(0x80 | (($cp & 0xFC0) >> 6)).chr(0x80 | ($cp & 0x3F));
    }else if ($cp > 0x80){    # 2 bytes
        return chr(0xC0 | (($cp & 0x7C0) >> 6)).chr(0x80 | ($cp & 0x3F));
    }else{                    # 1 byte
        return chr($cp);
    }
}
    
$result = $weixin->create_menu($button);

var_dump($result);
?>

 

posted @ 2019-07-15 15:08 方倍工作室 阅读(...) 评论(...) 编辑 收藏