当前位置: 首页>>代码示例>>PHP>>正文


PHP Wechat::getMenu方法代码示例

本文整理汇总了PHP中Wechat::getMenu方法的典型用法代码示例。如果您正苦于以下问题:PHP Wechat::getMenu方法的具体用法?PHP Wechat::getMenu怎么用?PHP Wechat::getMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wechat的用法示例。


在下文中一共展示了Wechat::getMenu方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     import('Vendor.Wechat.Wechat');
     $option = array('token' => 'weixin', 'appid' => 'wx444c22311a33b40d', 'secret' => 'f39ae15e9d86c293edbff26a9c47af6e');
     $wechatObj = new \Wechat($option);
     $wechatObj->valid();
     //解析来向XML
     $msg = $wechatObj->getRev();
     $message['fromUsername'] = $msg->getRevFrom();
     $message['toUsername'] = $msg->getRevTo();
     $message['type'] = $msg->getRevType();
     $message['createtime'] = $msg->getRevCtime();
     $message['keyword'] = $msg->getRevContent();
     $message['event'] = $msg->getRevEvent();
     //保存新用户相关信息
     $status = D('Member');
     $status->InsertNewer($message['fromUsername']);
     //主要部分,暂时仅使用TEXT,EVENT两种
     switch ($message['type']) {
         case $wechatObj::MSGTYPE_TEXT:
             $text = A('Text');
             $ret = $text->textSkip($message);
             if ('text' == $ret['type']) {
                 $wechatObj->text($ret['content'])->reply();
             } else {
                 if ('news' == $ret['type']) {
                     $wechatObj->news($ret['content'])->reply();
                 }
             }
             break;
         case $wechatObj::MSGTYPE_EVENT:
             $event = A('Event');
             $ret = $event->eventSkip($message);
             if ('text' == $ret['type']) {
                 $wechatObj->text($ret['content'])->reply();
             } else {
                 if ('news' == $ret['type']) {
                     $wechatObj->news($ret['content'])->reply();
                 }
             }
             break;
         default:
             $wechatObj->text('更多功能正在研发中,敬请期待')->reply();
     }
     //获取菜单
     $menu = $wechatObj->getMenu();
     //创建菜单
     $newmenu = array('小瓜神力' => array(array('type' => 'click', 'name' => '新生专题', 'key' => 'V1001_01_01'), array('type' => 'click', 'name' => '校车时刻', 'key' => 'V1001_01_02'), array('type' => 'click', 'name' => '交通导航', 'key' => 'V1001_01_03'), array('type' => 'click', 'name' => '考试成绩', 'key' => 'V1001_01_04'), array('type' => 'click', 'name' => '图书信息', 'key' => 'V1001_01_05')), '军训专题' => array(array('type' => 'click', 'name' => '通知公告', 'key' => 'V1001_02_01'), array('type' => 'click', 'name' => '军训快报', 'key' => 'V1001_02_02'), array('type' => 'click', 'name' => '军营风采', 'key' => 'V1001_02_03'), array('type' => 'view', 'name' => '军歌嘹亮', 'url' => 'http://mp.weixin.qq.com/s?__biz=MjM5OTIxMTM2Mg==&mid=209183345&idx=1&sn=96c4cf9ad618e5e051167456210d9fe8&scene=5&srcid=OJ8qMfaW9nS5T0jFFjQj#rd'), array('type' => 'click', 'name' => '微军训', 'key' => 'V1001_02_05')), '小瓜威武' => array(array('type' => 'click', 'name' => '小瓜在线', 'key' => 'V1001_03_01'), array('type' => 'click', 'name' => '跑操查询', 'key' => 'V1001_03_02'), array('type' => 'view', 'name' => '瓜棚论坛', 'url' => 'http://npuxiaogua.mgschool.cn/wx/apps/liuyan/'), array('type' => 'view', 'name' => '失物招领', 'url' => 'http://npuxiaogua.mgschool.cn/wx/npuxg_blog/wxq/index.php'), array('type' => 'click', 'name' => '表白墙', 'key' => 'V1001_03_05')));
     $result = $wechatObj->createMenu($newmenu);
 }
开发者ID:partholon,项目名称:xiaogua,代码行数:50,代码来源:IndexController.class.php

示例2: array

<?php

include "wechat.class.php";
$options = array('token' => 'tokenaccesskey', 'encodingaeskey' => '5lLtUYtyRLDM5zCuG43TxcHpKSK5ydENbozq78XhIOi');
$weObj = new Wechat($options);
$weObj->valid();
//明文或兼容模式可以在接口验证通过后注释此句,但加密模式一定不能注释,否则会验证失败
// 获取菜单操作:
$menu = $weObj->getMenu();
// 设置菜单
$newmenu = array("button" => array(array('name' => '医院信息', 'sub_button' => array(array("type" => "view", 'name' => '医院主页', "url" => "http://www.blkqyy.com/"), array("type" => "click", 'name' => '门诊时间', "key" => "time"), array("type" => "view", 'name' => '医院地址', "url" => "http://blkqyy.com/wap.php/index-map.html"), array("type" => "view", 'name' => '专业团队', "url" => "http://mp.weixin.qq.com/s?__biz=MzA3NDEyMTcxMw==&mid=202512101&idx=1&sn=478061005d164632ccbb3a79b36d5e85#rd"))), array('name' => '就医导航', 'sub_button' => array(array('type' => 'click', 'name' => '常见咨询', 'key' => 'quest'), array('type' => 'click', 'name' => '我要留言', 'key' => 'liuyan'), array('type' => 'view', 'name' => '来院导航', 'url' => 'http://map.wap.soso.com/x/index.jsp?welcomeChange=1&sid=AfYicfAV0b1upF4O4-Lnzj_z&welcomeClose=1&hideAdvert=hide&type=infowindow&open=1&address=中国浙江省宁波市北仑区星中路7号&name=宁波市北仑口腔&referer=weixinmp_profile&g_ut=3&Y=29.910579&X=121.84133&Z=16&from=singlemessage&'), array('type' => 'view', 'name' => '在线咨询', 'url' => 'http://dx.zoosnet.net/lrserver/LR/Chatpre.aspx?id=LZS32497012'))), array('name' => '爱牙知识', 'sub_button' => array(array('type' => 'view', 'name' => '成人宣教视频', 'url' => 'http://mp.weixin.qq.com/s?__biz=MzA3NDEyMTcxMw==&mid=200521821&idx=1&sn=1272b4da141a38ab66bfab0d1e64b4b4#rd'), array('type' => 'view', 'name' => '儿童宣教视频', 'url' => 'http://mp.weixin.qq.com/s?__biz=MzA3NDEyMTcxMw==&mid=200276316&idx=1&sn=8695db64330bd7129786e2b4f769c32c#rd'), array('type' => 'view', 'name' => '爱牙知识讲堂', 'url' => 'http://mp.weixin.qq.com/s?__biz=MzA3NDEyMTcxMw==&mid=203297479&idx=1&sn=dd41afb15383148c9b353e61e210d394#rd'), array('type' => 'view', 'name' => '最新资讯', 'url' => 'http://mp.weixin.qq.com/s?__biz=MzA3NDEyMTcxMw==&mid=203379412&idx=1&sn=39fc677860d67d5fea82ff924cde88a4#rd')))));
$result = $weObj->createMenu($newmenu);
$type = $weObj->getRev()->getRevType();
$revfrom = $weObj->getRev()->getRevFrom();
$getrevto = $weObj->getRev()->getRevTo();
switch ($type) {
    case Wechat::MSGTYPE_TEXT:
        $msg = $weObj->getRev()->getRevContent();
        switch ($msg) {
            case 'openid':
                //get openid
                $openid = $weObj->getRev()->getRevFrom();
                $weObj->text('openid:' . $openid)->reply();
                break;
            case '预约查询':
                $newsData = array($item = array('Title' => '预约查询', 'Description' => '点击查看', 'Url' => 'www.blkqyy.com/admin.php/message/add_yuyue.html?weixin_id=' . $topmsg['fakeid']));
                $weObj->news($newsData)->reply();
                break;
            default:
                $weObj->text("您的消息我们已经收到,感谢您的支持!")->reply();
                break;
开发者ID:dlpc,项目名称:weixin_php_sdk,代码行数:31,代码来源:demo.php

示例3: header

<?php

include 'config.php';
include 'wechat-php-sdk/wechat.class.php';
$key = $_GET['key'];
$act = $_GET['act'];
$id = $_GET['id'];
if (strlen($siteData['getKey']) && $key !== $siteData['getKey']) {
    header('Location:' . $siteData['homePage']);
}
$options = array('token' => $siteData['wechatToken'], 'appid' => $siteData['wechatAppID'], 'appsecret' => $siteData['wechatAppSecret']);
$weObj = new Wechat($options);
// 查询菜单
if ($act === 'getMenu') {
    var_dump($weObj->getMenu());
    exit;
}
if ($act === 'createMenu') {
    $data = array('button' => array(array('type' => 'view', 'name' => '伍 & 熊', 'url' => 'http://wedding.ciaoca.com/'), array('name' => '参加婚礼', 'sub_button' => array(array('type' => 'click', 'name' => '我的喜帖', 'key' => '喜帖'), array('type' => 'click', 'name' => '婚宴酒店', 'key' => '地址'))), array('name' => '精彩互动', 'sub_button' => array(array('type' => 'view', 'name' => '祝福新人', 'url' => 'http://wedding.ciaoca.com/blessing.php'), array('type' => 'click', 'name' => '幸福瞬间', 'key' => '照片分享'), array('type' => 'pic_photo_or_album', 'name' => '照片分享', 'key' => 'photo_share')))));
    $weObj->createMenu($data);
    exit;
}
开发者ID:juanjuanwang,项目名称:wedding,代码行数:22,代码来源:wechat-push.php


注:本文中的Wechat::getMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。