當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。